aliostad / CacheCow

An implementation of HTTP Caching in .NET Core and 4.5.2+ for both the client and the server
MIT License
849 stars 171 forks source link

RedisEntityTagStore, why we need different keys for Etag, Uri and Pattern? #180

Closed flowdopip closed 7 years ago

flowdopip commented 7 years ago

public void AddOrUpdate(CacheKey key, TimedEntityTagHeaderValue eTag) { _database.StringSet(key.HashBase64, eTag.ToString(), _expiry);

        // resource
        var resourceKey = string.Format(ResourceFormat, key.ResourceUri);
        _database.SetAdd(resourceKey, key.HashBase64);
        if (_expiry.HasValue)
            _database.KeyExpire(resourceKey, _expiry);

        // routePattern
        var routePatternKey = string.Format(RoutePatternFormat, key.RoutePattern);
        _database.SetAdd(routePatternKey, key.HashBase64);
        if (_expiry.HasValue)
            _database.KeyExpire(routePatternKey, _expiry);

    }

this is a behavior of redis? something to improve performance?

aliostad commented 7 years ago

Sorry, what exactly you mean is the behaviour of Redis? Can you please elaborate, what specifically?

App we are doing here is to store the data and if there is expiry, set that on the key. I cannot see anything strange here.