English 中文(简体)
在应用过程中添加纳米数据Cache方案
原标题:Adding Named Data Cache Programmatically in Appfabric

I want to add named data cache programmatically in appfabric. I kept following code for this :-

    try
    {
        //This can also be kept in a config file
        var config = new DataCacheFactoryConfiguration();
        config.SecurityProperties = new DataCacheSecurity();

        config.Servers = new List<DataCacheServerEndpoint> { new DataCacheServerEndpoint(Environment.MachineName, 22233) };

        DataCacheFactory dcf = new DataCacheFactory(config);

        if (dcf != null)
        {
            var state = InitialSessionState.CreateDefault();
            state.ImportPSModule(new string[] { "DistributedCacheAdministration", "DistributedCacheConfiguration" });
            state.ThrowOnRunspaceOpenError = true;
            var rs = RunspaceFactory.CreateRunspace(state);
            rs.Open();
            var pipe = rs.CreatePipeline();
            pipe.Commands.Add(new Command("Use-CacheCluster"));

            var cmd = new Command("New-Cache");
            cmd.Parameters.Add(new CommandParameter("Name", "Vaibhav"));

            cmd.Parameters.Add(new CommandParameter("Expirable", false));
            pipe.Commands.Add(cmd);

            var output = pipe.Invoke();
        }
    }
    catch (Exception e)
    {
        //throw new Exception 
    }

But this is not working as expected when i try to access the DataCache (using: dcf.GetCache("Vaibhav");) it is giving Cache not found error. When i created the Cache using powershell it worked fine and i was able to access the Cache, but i want to implement this programmactically and not by Command Prompt(powershell)

请建议采取适当方式落实这一条。

Thanks in Advance Vaibhav

最佳回答

你们实际上必须开始视像演播室,作为行政,能够以方案方式创造切身。

问题回答

暂无回答




相关问题
Write-though caching of large data sets in WCF?

We ve got a smart client that talks to a SQL Server database via WCF, displaying the entities in the database, and allowing the user to edit those entities. Some of the WCF calls return a large data ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

how to tell clicking "back" to load cache?

I would like for my site when someone clicks "Back" or "Forward" for the server to tell the browser to load the cache instead of reloading the entire page. I ve tested some headers and done research, ...

java plugin cache and dynamic IP host

I m trying to use Amazon S3 and Amazon Cloudfront CDN to deliver the jar files of my applet application. I m seeing several cache misses of my jars by the java plugin. This is a show-stopper for me, ...

Frequently Used metadata Hashmap

Are there any implementations of a static size hashtable that limits the entries to either the most recently or most frequently used metadata? I would prefer not to keep track of this information ...

PHP - Memcache - HTML Caching

I would like to create a caching system that will bypass some mechanisms in order to improve the performance. I have some examples: 1-) I have a dynamic PHP page that is updated every hour. The page ...

Performance of Sql subqueriesfunctions

I am currently working on a particularly complex use-case. Simplifying below :) First, a client record has a many-to-one relationship with a collection of services, that is, a single client may have ...

热门标签