{"id":16367174,"url":"https://github.com/snower/slock4net","last_synced_at":"2026-02-21T16:30:16.926Z","repository":{"id":142582233,"uuid":"445734427","full_name":"snower/slock4net","owner":"snower","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-29T06:34:20.000Z","size":152,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-24T22:33:18.256Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snower.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-08T05:40:27.000Z","updated_at":"2024-05-29T06:32:30.000Z","dependencies_parsed_at":"2024-05-20T04:25:55.729Z","dependency_job_id":null,"html_url":"https://github.com/snower/slock4net","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fslock4net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fslock4net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fslock4net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fslock4net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snower","download_url":"https://codeload.github.com/snower/slock4net/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239850437,"owners_count":19707350,"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":[],"created_at":"2024-10-11T02:48:50.645Z","updated_at":"2026-02-21T16:30:16.863Z","avatar_url":"https://github.com/snower.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slock4net\n\n[![Tests](https://img.shields.io/github/actions/workflow/status/snower/slock4net/build-test.yml?label=tests)](https://github.com/snower/slock4net/actions/workflows/build-test.yml)\n[![GitHub Repo stars](https://img.shields.io/github/stars/snower/slock4net?style=social)](https://github.com/snower/slock4net/stargazers)\n\nHigh-performance distributed sync service and atomic DB. Provides good multi-core support through lock queues, high-performance asynchronous binary network protocols. Can be used for spikes, synchronization, event notification, concurrency control. https://github.com/snower/slock\n\n# Install\n\n```bash\nNuGet\\Install-Package slock4net -Version 1.0.3\n```\n\n# Client Lock\n\n```C#\nusing slock4net.Exceptions;\nusing slock4net;\n\nSlockClient client = new SlockClient(\"localhost\", 5658);\ntry\n{\n    client.Open();\n    Lock lck = client.NewLock(\"test\", 5, 5);\n    lck.Acquire();\n    lck.Release();\n}\ncatch (IOException e) {\n    Console.WriteLine(e.ToString());\n}\ncatch (SlockException e) {\n    Console.WriteLine(e.ToString());\n} finally\n{\n    client.Close();\n}\nConsole.WriteLine(\"Success\");\n```\n\n# Replset Client Lock\n\n```C#\nusing slock4net.Exceptions;\nusing slock4net;\n\nSlockReplsetClient replsetClient = new SlockReplsetClient(new String[] { \"localhost:5658\" });\ntry\n{\n    replsetClient.Open();\n    Lock lck = replsetClient.NewLock(\"test\", 5, 5);\n    lck.Acquire();\n    lck.Release();\n}\ncatch (IOException e) {\n    Console.WriteLine(e.ToString());\n}\ncatch (SlockException e) {\n    Console.WriteLine(e.ToString());\n} finally\n{\n    replsetClient.Close();\n}\nConsole.WriteLine(\"Success\");\n```\n\n# Async Client Lock\n\n```C#\nusing slock4net.Exceptions;\nusing slock4net;\n\nasync Task TestLock()\n{\n    SlockReplsetClient replsetClient = new SlockReplsetClient(new String[] { \"localhost:5658\" });\n    try\n    {\n        await replsetClient.OpenAsync();\n        Lock lck = replsetClient.NewLock(\"test\", 5, 5);\n        await lck.AcquireAsync();\n        await lck.ReleaseAsync();\n    }\n    catch (IOException e)\n    {\n        Console.WriteLine(e.ToString());\n    }\n    catch (SlockException e)\n    {\n        Console.WriteLine(e.ToString());\n    }\n    finally\n    {\n        await replsetClient.CloseAsync();\n    }\n}\nTestLock().Wait();\nConsole.WriteLine(\"Success\");\n```\n\n# Event\n\n```C#\nusing slock4net.Exceptions;\nusing slock4net;\n\nSlockClient client = new SlockClient(\"localhost\", 5658);\ntry\n{\n    client.Open();\n    Event event1 = client.NewEvent(\"test\", 5, 5, true);\n    event1.Clear();\n\n    Event event2 = client.NewEvent(\"test\", 5, 5, true);\n    event2.Set(\"{\\\"value\\\": 10}\");\n\n    event1.Wait(10);\n    Console.WriteLine(event1.CurrentLockDataAsString);\n}\ncatch (IOException e) {\n    Console.WriteLine(e.ToString());\n}\ncatch (SlockException e) {\n    Console.WriteLine(e.ToString());\n} finally\n{\n    client.Close();\n}\nConsole.WriteLine(\"Success\");\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Fslock4net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnower%2Fslock4net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Fslock4net/lists"}