This project is read-only.

Optimization Feedback

Mar 15, 2009 at 8:39 AM
Good day,
first of all; the code is clean, much better than some of the other memcached projects I've come across.

I quickly looked over all the files attached in the project and came across a few things that brought up some questions:

1. In MemcachedClient.cs
The Store(..) procedures are casting StoreMode to StoreCommand, looking at the two enumerations, they are exactly identical, but the store command has options for Append, Prepend, CheckAndSet.
Why not skip the casting and directly just pass through a StoreCommand enumeration value? Might not be a worthwhile optimization, but I'd like to hear why this approach was followed.

2. In DistCache.cs
Having all the methods static is definitely a benefit ( not having to instantiate a client object on every call ), but I have a major concern. All the static methods call LoadProvider that loads the section information from disk, which means there's unneccesary disk IO. Since the whole project revolves around in-memory-caching, why not cache the section object and load it from the memcached server instance/s and if it doesn't exist, load it normally?

3. Session-> Common.cs
DbType is a static class with static functions to return a name of a specific provider, ex. MySQL() returns "MySQL". Is this approach more effective than just using an enumeration?

4. SQLDbOperations.cs
private SqlParameter GetParameter(string strName, ParameterDirection direction)
        {
            SqlParameter obj = new SqlParameter();
            obj.ParameterName = strName;
            obj.Direction = direction;
            return obj;
        }
-->
private SqlParameter GetParameter(string strName, SqlDbType type, ParameterDirection direction)
        {
            SqlParameter obj = new SqlParameter();
            obj.ParameterName = strName;
            obj.SqlDbType = type;
            obj.Direction = direction;
            return obj;
        }
Why not used typed parameters instead? From what I've read, it isn't the database servers' role to do explicit type conversions.


Hope I didn't rattle too many cages, but I see a bright future for this project.