Coder Social home page Coder Social logo

Comments (8)

VahidN avatar VahidN commented on June 15, 2024 1

You are using V2.6.3. Please update it to 2.6.4, because it considers ConstantExpression value's in final hash. In this case you won't see the same cache-keys.

from efsecondlevelcache.core.

VahidN avatar VahidN commented on June 15, 2024 1

I tested your ext method and it works fine (creates 2 different cache-keys for 2 different inputs):
issue53_@

from efsecondlevelcache.core.

kooshanabedian avatar kooshanabedian commented on June 15, 2024

Note that the Id property is located on an aggregate base class and inherited by other classes, if it matters in any way.

from efsecondlevelcache.core.

VahidN avatar VahidN commented on June 15, 2024

I can't reproduce it. Try this sample.
Using 2 different parameters will create 2 different cache-keys with different results from the cache:
issue53

from efsecondlevelcache.core.

kooshanabedian avatar kooshanabedian commented on June 15, 2024

Indeed. Here is my sample for three different values for Id parameter. It generates three different records in Redis but all of them referencing the same hash.

Records:

1

2

3

4

Data:
5

from efsecondlevelcache.core.

kooshanabedian avatar kooshanabedian commented on June 15, 2024

You are right. my bad. updating to 2.64. fixes the issue for cases where I directly use DbContext.
If I use some extension methods on DbContext to get some form of a repository pattern,
I'm stuck again. But I guess that's some misuse on my part.

public static async Task<TEntity> GetFirstOrDefaultAsync<TEntity,TDbContext>(this TDbContext dbContext, Expression<Func<TEntity, bool>>? predicate = null,
                                                Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>>? orderBy = null,
                                                Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>>? include = null,
                                                bool disableTracking = true,
                                                CancellationToken cancellationToken = default(CancellationToken))
            where TEntity : class
            where TDbContext : CacheawareDbContext
        {
            IQueryable<TEntity> query = dbContext.Set<TEntity>();
            if (disableTracking)
            {
                query = query.AsNoTracking();
            }

            if (include != null)
            {
                query = include(query);
            }

            if (predicate != null)
            {
                query = query.Where(predicate);
            }

            if (orderBy != null)
            {
                    return await orderBy(query)
                            .Cacheable(cacheExpirationMode,timeSpan.Value)
                            .FirstOrDefaultAsync(cancellationToken);
            }
            else
            {
                    return await query
                            .Cacheable(cacheExpirationMode,timeSpan.Value)
                            .FirstOrDefaultAsync(cancellationToken);
            }
        }

from efsecondlevelcache.core.

kooshanabedian avatar kooshanabedian commented on June 15, 2024

Thank you for your help. I do very much appreciate it. I'm closing this now, since I couldn't track the core issue, which is obviously on my par.

from efsecondlevelcache.core.

lock avatar lock commented on June 15, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.

from efsecondlevelcache.core.

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.