GithubHelp home page GithubHelp logo

tagcache.redis's People

Contributors

advertisingstudio avatar crescentfresh avatar jmenziessmith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tagcache.redis's Issues

Next steps

Hi,

So we have a good selection of serializers, migrated to StackExchange and good test coverage.
What do you suggest are the next steps?

I would personally love to be able to use Protobuf without having to manually decorate every cached object so I'm going to try to see if using reflection to setup the serialization is worth it.

I guess there is still a bit of cleaning-up/refactoring we can do but as it is, it's working well in tests on my applications.

After that I guess it would be great if someone jumped in to make a small GitHub page to showcase the library and how to use it.

Except for NCache (which is commercial), there aren't many .NET caching libraries that support tags so there's that.

Unit tests using Json and Xml serializers is missing

I have run the current unit tests with the Json serializer and because CacheItem is serialized and the Value property is of type object, Value's type is lost on deserialization (it becomes a dynamic Newtonsoft.Json.Linq.JObject).

It works with the Binary serializer as it stores metadata but not Json.

All the unit tests (except the serializer-specific ones) should be run with all 3 serializer providers.

To solve the issue I think I'm going to make CacheItem generic which will also remove a cast in Get(string key).

Error when deserializing with Json.Net

Repro:

Reference TagCache.Redis.Json.Net

void Main()
{
    var redisConnMgr = new TagCache.Redis.RedisConnectionManager("localhost");
    var config = new TagCache.Redis.CacheConfiguration(redisConnMgr)
    {
        Serializer = new TagCache.Redis.Json.Net.JsonSerializationProvider(),
    };
    var cacheProvider = new TagCache.Redis.RedisCacheProvider(config);

    cacheProvider.Set("foo", new Foo(), DateTime.UtcNow + TimeSpan.FromMinutes(5));
    /*
    {
        "Value": {
            "Bar": "baz"
        },
        "Key": "foo",
        "Tags": null,
        "Expires": "2016-01-13T15:10:21.837778Z"
    }
    */

    cacheProvider.Get<Foo>("foo");
    // ERROR:
    // Could not create an instance of type 
    // TagCache.Redis.Interfaces.IRedisCacheItem`1[Foo].
    // Type is an interface or abstract class and cannot be instantiated.
}

public class Foo
{
    public string Bar = "baz";
}

Expected outcome: json at redis key "foo" successfully deserialized into type Foo.

Actual outcome: json.net error:
Could not create an instance of type TagCache.Redis.Interfaces.IRedisCacheItem`1[Foo]. Type is an interface or abstract class and cannot be instantiated. Path 'Value', line 1, position 9.

Do we need to wrap cached items in a RedisCacheItem?

I'm working out some issues with my AutoProtobuf library, specifically support for DataTable and other things. I was wondering if we could do without wrapping items inside a RedisCacheItem.

It would save a tiny bit of overhead, allow using specialized serializers like protobuf-net-data. RedisCacheItem is not exactly indispensable in the current implementation and adds a few headaches including the attribute decoration issue that you want to solve with a factory.

Have a non-strongname SE.Redis dependency

Is there a technical reason why StackExchange.Redis.StrongName was chosen (vs StackExchange.Redis)?

The issue we are having is we cannot use this package and interop with our existing SE.Redis-dependent code (we have no need for strongly signed dependencies).

For example:

InHouseRedisUtil.dll (depends on StackExchange.Redis):

void TryRedis(Action action)
{
  try
  {
    action();
  }
  catch(StackExchange.Redis.RedisConnectionException e) // <-- VANILLA SE.Redis here
  {
    // bunch of custom logic to requeue the operation,
    // avoid loss of data, etc, etc
  }
}

Application code (depends on TagCache.Redis.dll and InHouseRedisUtil.dll):

InHouseRedisUtil.TryRedis(() => SomeTagCacheRedisOperation());

The two codebases cannot interop even though it's the exact same SE.Redis code underneath.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.