{"id":27306461,"url":"https://github.com/bcuff/memcachedsharp","last_synced_at":"2025-04-12T04:00:00.404Z","repository":{"id":7678097,"uuid":"9040772","full_name":"bcuff/MemcachedSharp","owner":"bcuff","description":"A light-weight, async/non-blocking Memcached client for .NET","archived":false,"fork":false,"pushed_at":"2017-02-26T21:44:53.000Z","size":346,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T03:59:56.003Z","etag":null,"topics":["c-sharp","memcached","memcachedclient"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcuff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-26T21:25:15.000Z","updated_at":"2019-08-04T08:44:58.000Z","dependencies_parsed_at":"2022-09-07T13:21:50.137Z","dependency_job_id":null,"html_url":"https://github.com/bcuff/MemcachedSharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcuff%2FMemcachedSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcuff%2FMemcachedSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcuff%2FMemcachedSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcuff%2FMemcachedSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcuff","download_url":"https://codeload.github.com/bcuff/MemcachedSharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514224,"owners_count":21116901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","memcached","memcachedclient"],"created_at":"2025-04-12T03:59:59.640Z","updated_at":"2025-04-12T04:00:00.395Z","avatar_url":"https://github.com/bcuff.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"MemcachedSharp\n==============\n\nA light-weight, async/non-blocking Memcached client for .NET\n\n#Install on NuGet\n\n\u003e Install-Package MemcachedSharp\n\n#Setup and Options\n```c#\nvar client = new MemcachedClient(\"somehost:11211\", new MemcachedOptions\n{\n\t// setup my options here\n\tConnectTimeout = TimeSpan.FromSeconds(2),\n\tReceiveTimeout = TimeSpan.FromSeconds(2),\n\tEnablePipelining = true,\n\tMaxConnections = 2,\n\tMaxConcurrentRequestPerConnection = 15\n});\n```\n####ConnectTimeout\nThe amount of time to wait before abandoning an attempt to connect to a Memcached host.\n* Default: 2 seconds, ```TimeSpan.FromSeconds(2)```.\n* Infinite timeout: -1 millisecond, ```Timeout.InfiniteTimeSpan``` or ```TimeSpan.FromMilliseconds(-1)```.\n\n####ReceiveTimeout\nThe amount of time to wait before abandoning an attempt to receive more data from a Memcached host.\nPlease note that requests may take longer than the specified receive timeout. This timeout only limits the amount of time that a connection may remain idle when data is expected.\n* Default: 2 seconds, ```TimeSpan.FromSeconds(2)```.\n* Infinite timeout: -1 millisecond, ```Timeout.InfiniteTimeSpan``` or ```TimeSpan.FromMilliseconds(-1)```.\n\n####EnablePipelining\nEnables the client to send multiple requests on the same connection before receiving any of the responses. This works a lot like [http pipelining](http://en.wikipedia.org/wiki/HTTP_pipelining).\n* Default: true\n\n####MaxConnections\nThe maximum number of connections that may be opened at one time to the target host. Note that this number doesn't need to be very high to achieve high throughput if pipelining is enabled.\n* Default: 2\n\n####MaxConcurrentRequestPerConnection\nThe maximum number of requests that may be sent at one time on the same connection.\n* Default: 15\n* Only applicable if EnablePipelining is true.\n\n#Example\n\n```c#\nusing System;\nusing MemcachedSharp;\nusing System.Threading.Tasks;\n\nusing(var client = new MemcachedClient(\"localhost:11211\"))\n{\n\tConsole.Write(\"get foo...\");\n\tvar foo = await client.Get(\"foo\");\n\tConsole.WriteLine(foo == null ? \"not found.\" : \"found.\");\n\t\n\tConsole.Write(\"set foo...\");\n\tawait client.Set(\"foo\", Encoding.UTF8.GetBytes(\"Hello, World!\"));\n\tConsole.WriteLine(\"done.\");\n\t\n\tConsole.Write(\"get foo...\");\n\tfoo = await client.Get(\"foo\");\n\tConsole.WriteLine(foo == null ? \"not found.\" : \"found.\");\n\tfoo.Dump(\"Foo\");\n\t\n\tConsole.Write(\"delete foo...\");\n\tawait client.Delete(\"foo\");\n\tConsole.WriteLine(foo == null ? \"not found.\" : \"deleted.\");\n\t\n\tConsole.Write(\"get foo...\");\n\tfoo = await client.Get(\"foo\");\n\tConsole.WriteLine(foo == null ? \"not found.\" : \"found.\");\n}\n```\n\n#MemcachedClient\n\n* Instances are stateful. Connections are created the first time they are needed and persist as long as the MemcachedClient instance exists.\n* Instances should be disposed when they are no longer needed. Doing so will close pooled connections to Memcached.\n* For long-lived applications with periodic requests to Memcached I recommend keeping a single instance alive for the life-time of the application.\n\n###Operations\n```c#\npublic class MemcachedClient : IDisposable\n{\n    Task\u003cMemcachedItem\u003e Get(string key);\n    Task\u003cMemcachedItem\u003e Gets(string key);\n    Task Set(string key, byte[] value, MemcachedStorageOptions options = null);\n    Task\u003cbool\u003e Delete(string key);\n    Task\u003cbool\u003e Add(string key, byte[] value, MemcachedStorageOptions options = null);\n    Task\u003cbool\u003e Replace(string key, byte[] value, MemcachedStorageOptions options = null);\n    Task\u003cbool\u003e Append(string key, byte[] value, MemcachedStorageOptions options = null);\n    Task\u003cbool\u003e Prepend(string key, byte[] value, MemcachedStorageOptions options = null);\n    Task\u003culong?\u003e Increment(string key, ulong value);\n    Task\u003culong?\u003e Decrement(string key, ulong value);\n    Task\u003cCasResult\u003e Cas(string key, long casUnique, byte[] value, MemcachedStorageOptions options = null);\n}\n```\n\n###MemcachedItem\n```c#\n// Encapsulates a response object from Memcached.\npublic class MemcachedItem\n{\n    // The key of the object retrieved from Memcached;\n    public string Key { get; }\n    \n    // The flags value of the object retrieved from Memcached.\n    public uint Flags { get; }\n\n    // The size of the object retrieved from Memcached.\n    public long Size { get; }\n\n    // The cas unique field of the object retrieved from Memcached.\n    public long? CasUnique { get; }\n\n    // A Stream of the data retrieved from Memcached.\n    public Stream Data { get; }\n}\n```\n\n###MemcachedStorageOptions\n```c#\n// Encapsulates options for storage operations in Memcached.\npublic class MemcachedStorageOptions\n{\n    // The flags field on the object to store in Memcached.\n    public uint Flags { get; set; }\n\n    // The expires field on the object to store in Memcached.\n    public TimeSpan? ExpirationTime { get; set; }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcuff%2Fmemcachedsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcuff%2Fmemcachedsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcuff%2Fmemcachedsharp/lists"}