Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6746057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:16:41+00:00 2026-05-26T12:16:41+00:00

I just installed membase and the enyim client for .NET, and came across an

  • 0

I just installed membase and the enyim client for .NET, and came across an article that mentions this technique for integrating linq:

    public static IEnumerable<T> CachedQuery<T>
        (this IQueryable<T> query, MembaseClient cache, string key) where T : class
    {
        object result; 
        if (cache.TryGet(key, out result))
        {
            return (IEnumerable<T>)result;
        }
        else
        {
            IEnumerable<T> items = query.ToList();
            cache.Store(StoreMode.Set, key, items);
            return items;
        }
    }

It will check if the required data is in cache first, and if not cache it then return it.

Currently I am using a Dictionary<'String, List'> in my application and want to replace this with a membase/memcached type approach.

What about a similar pattern for adding items to a List<‘T’> or using Linq operators on a cached list? It seems to me that it could be a bad idea to store an entire List<‘T’> in cache under a single key and have to retrieve it, add to it, and then re-set it each time you want to add an element. Or is this an acceptable practice?

    public bool Add(T item)
    {
        object list;
        if (cache.TryGet(this.Key, out list))
        {
            var _list = list as List<T>;
            _list.Add(item);
            return cache.Store(StoreMode.Set, this.Key, _list); 
        }
        else
        {
            var _list = new List<T>(new T[] { item });
            return cache.Store(StoreMode.Set, this.Key, _list); 
        }
    }

How are collections usually handled in a caching situation like this? Are hashing algorithms usually used instead, or some sort of key-prefixing system to identify ‘Lists’ of type T within the key-value store of the cache?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:16:42+00:00Added an answer on May 26, 2026 at 12:16 pm

    It depends on several factors:
    Is this supposed to be scalable? Is this list user-specific and you can be certain that “Add” won’t be called twice at the same time for the same list? – Race conditions are a risk.

    I did implement such a thing where I stored a generic list in membase, but it’s user-specific, so I can be pretty certain that there will be no race condition.

    You should also consider the volume of the serialized list, which may be large. I my case the lists were pretty small.

    Not sure if it helps, but I implemented a very basic iterateable list with random access over membase (via double indirection). Random access is done via a composite key (which is composed of several fields).

    You need to:

    1. Have a key that holds the list’s length.
    2. Have the ability to build the composite key (e.g one or more fields from your object).
    3. Have the value that you’d like save (e.g. another field).

    E.g:

    list_length = 3

    prefix1_0-> prefix2_[field1.value][field2.value][field3.value] -> field4.value

    prefix1_1-> prefix2_[field1.value][field2.value][field3.value] -> field4.value

    prefix1_2-> prefix2_[field1.value][field2.value][field3.value] -> field4.value

    To perform serial access you iterate over the keys with “prefix1”. To perform random access you use the keys with “prefix2” ans the fields that compose the key.

    I hope it’s clear enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just installed and migrated a 2008 solution on Vista ultimate 64 and .net 4.0.
I just installed python2.6 parallel to my python2.4. I ran this command ln -s
just installed new ubuntu vm to test around with node installed things in this
Just installed phonegap 2.3 and tried to open a maps link that i've created.
Just installed VS2012 and run across a strange behavior by the one click publish
I just installed Java 1.6 on my OSX and everything works brilliantly, except that
Just installed POI 3.8 jars and changing over code...I get this error: public static
just installed asp.net mvc 2, where are the new .dll's?
Just installed Xcode 4 so far so good, except that Apple changed all the
Just installed SL5 and the toolkit, that were released few days ago. The bug

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.