Coder Social home page Coder Social logo

Comments (6)

ErikPilsits-RJW avatar ErikPilsits-RJW commented on June 16, 2024 1

Thanks, I will try this out shortly. However I've got another issue, and I can open a bug report if you like. I'm trying a basic redis backed setup. SetAsync works, but GetOrSetAsync is not setting the value into redis. It is setting the value into memory however, and does return the expected value.

If I remove the redis extensions, then it works and does set the value into redis. However I can't really use redis without them, since I have scaled app services in azure. Note I need to remove both redis extensions, having either one will cause the problem.

Here's a basic reproducer I mocked up in linqpad.

var redisConnection = ConnectionMultiplexer.Connect("-azure-cnxn-string-");

var c = new CacheStack(
    new ICacheLayer[]
    {
        new MemoryCacheLayer(),
        new RedisCacheLayer(redisConnection, 0)
    },
    new ICacheExtension[]
    {
        new AutoCleanupExtension(TimeSpan.FromMinutes(5)),
        new RedisLockExtension(redisConnection, 0),
        new RedisRemoteEvictionExtension(redisConnection)
    });

// works
var result1 = c.SetAsync("setasync", "hello world", TimeSpan.FromHours(24)).GetAwaiter().GetResult();
// doesn't work
var result2 = c.GetOrSetAsync<string>("getorsetasync", old => Task.FromResult("hello world"), new CacheSettings(TimeSpan.FromMinutes(2))).GetAwaiter().GetResult();
result1.Dump();
result2.Dump();

from cachetower.

Turnerj avatar Turnerj commented on June 16, 2024

Hey @ErikPilsits-RJW - thanks for raising an issue! There shouldn't be any issues with serializing with protobuf if you are decorating your types like protobuf.net requires:

  • ProtoContractAttribute on type
  • Each property to have a ProtoMemberAttribute on it

[ProtoContract]
public class ComplexTypeCaching_TypeOne : IEquatable<ComplexTypeCaching_TypeOne>
{
[ProtoMember(1)]
public int ExampleNumber { get; set; }
[ProtoMember(2)]
public string ExampleString { get; set; }
[ProtoMember(3)]
public List<int> ListOfNumbers { get; set; }

I did just realise though that my documentation doesn't say that anywhere so that is definitely on me for not being clear. I'll look at updating the documentation soon.

Now if you do have those attributes and are still having issues, please provide me with the model that is causing the issue to see if I can recreate it.

from cachetower.

Turnerj avatar Turnerj commented on June 16, 2024

Thanks for that detailed information about this other issue. It will be easiest to track it in a second issue, especially if the issues aren't caused by the some underlying problem, however I should be able to look into this in the next day or two.

from cachetower.

ErikPilsits-RJW avatar ErikPilsits-RJW commented on June 16, 2024

Thanks. The suggestion for the protobuf attributes seems to have resolved the error, however I'll need to see it in redis to be sure, which requires resolving the other issue. I'll open a new issue for that now.

from cachetower.

ErikPilsits-RJW avatar ErikPilsits-RJW commented on June 16, 2024

All good on the protobuf front after adding the attributes.

from cachetower.

Turnerj avatar Turnerj commented on June 16, 2024

Awesome, glad that solves this issue. Will definitely update the readme to better indicate this. 🙂

from cachetower.

Related Issues (20)

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.