disable second level cache

4 posts, 0 answers
  1. Diana
    Diana avatar
    2 posts
    Member since:
    Nov 2012

    Posted 04 Mar Link to this post

    Hello!
    We develop WPF and implemented data Access 2015.1.225.1 with cache level two, in some case we don't use information cache, we need data base information, configuring back-end over write SeconLevel property in false (SecondLevelCache.Enabled = false;)

    However, data returned correspond with cache information.
    How get data base information without set nocache value to entity in Cache Policy property (Cache Policy: NoCache)?

    Thanks!

  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 07 Mar Link to this post

    Hi Diana,

    do you want to fetch the data fresh from the database, avoiding stale data in the cache?
    Then you should either configure your database context instance so that no second level cache is used.
    Or remove the content from the second level cache via context.LevelTwoCache.Evict() method.
    Or is the issue that the data gets stale in the first place: Then you would need to configure second level cache synchronization. See

    http://docs.telerik.com/data-access/developers-guide/crud-operations/working-with-second-level-cache/data-access-tasks-enable-second-level-cache-enable-code

    for more information.

    Alternatively you could open a second database connection with a different backend configuration and use this non-caching database for the code parts that need fresh information. However, I would not recommend this as it easily leads to confusion and the data is still stale in the caching connection potentially.

    Regards,
    Thomas
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.

     
  3. DevCraft banner
  4. Diana
    Diana avatar
    2 posts
    Member since:
    Nov 2012

    Posted 07 Apr in reply to Thomas Link to this post

    Hi Thomas, 

    How  remove the content from the second level cache via context.LevelTwoCache.Evict() method?.

    thanks for your help!

  5. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 08 Apr Link to this post

    Hello Diana,

    the context.LevelTwoCache.Evict() is the method to evict the second level cache and all content will be removed from it. 

    Regards,
    Thomas
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Back to Top