{"id":16696939,"url":"https://github.com/seratch/memcachedweaver","last_synced_at":"2025-05-16T05:32:36.974Z","repository":{"id":57722719,"uuid":"2555368","full_name":"seratch/memcachedweaver","owner":"seratch","description":"Caching methods result on memcached with AOP","archived":false,"fork":false,"pushed_at":"2012-02-15T13:57:19.000Z","size":127,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-03T21:03:51.379Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seratch.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-10-11T13:20:37.000Z","updated_at":"2019-08-13T14:51:16.000Z","dependencies_parsed_at":"2022-08-28T08:40:51.429Z","dependency_job_id":null,"html_url":"https://github.com/seratch/memcachedweaver","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/seratch%2Fmemcachedweaver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fmemcachedweaver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fmemcachedweaver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fmemcachedweaver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seratch","download_url":"https://codeload.github.com/seratch/memcachedweaver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254474714,"owners_count":22077349,"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-12T17:45:21.631Z","updated_at":"2025-05-16T05:32:34.642Z","avatar_url":"https://github.com/seratch.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# memcachedweaver: Caching methods result on memcached with AOP\n\n## Getting Started\n\n### Maven\n\n```xml\n\u003cdependencies\u003e\n  \u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.seratch\u003c/groupId\u003e\n    \u003cartifactId\u003ememcachedweaver\u003c/artifactId\u003e\n    \u003cversion\u003e0.2\u003c/version\u003e\n  \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## Usage\n\n### Using as a wrapper API for memcached clients\n\nmemcachedweaver provides a pluggable wrapper API for memcached clients and developers can access memcached servers transparently.\n\nCurrently memcachedweaver supports following 2 libraries, and it's also possible to add new adaptors.\n\n#### memcacheweaver.client.adaptor.SpymemcachedAdaptor\n\n  for http://code.google.com/p/spymemcached/\n\n#### memcacheweaver.client.adaptor.XmemcachedAdaptor\n\n  for http://code.google.com/p/xmemcached/\n\n```java\nConfiguration config = new Configuration();\nconfig.setAdaptorClassName(\"memcachedweaver.client.adaptor.SpymemcachedAdaptor\");\nconfig.setAddressesAsString(\"server1:11211,server2:11211\"); // csv format\nMemcachedClient memcached = MemcachedClientFactory.create(config);\n\nThread.sleep(500L);\nString toBeCached = new java.util.Date().toString();\nmemcached.set(\"stopped time\", 1, toBeCached); // whitespace in cache key will be replaced to underscore\nThread.sleep(500L);\nassertThat(memcached.get(\"stopped time\"), is(equalTo(toBeCached))); // \"Wed Oct 12 00:01:54 JST 2011\"\nThread.sleep(1000L);\nassertThat(memcached.get(\"stopped time\"), is(nullValue())); // null\n```\n\n### Setup for Spring Framework\n\n\"applicationContext.xml\" as follows:\n\n```\n\u003cbean id=\"memcachedweaverConfiguration\" class=\"memcachedweaver.Configuration\"\u003e\n  \u003cproperty name=\"namespace\" value=\"com.example\" /\u003e\n  \u003cproperty name=\"adaptorClassName\" value=\"memcachedweaver.client.adaptor.SpymemcachedAdaptor\" /\u003e\n  \u003cproperty name=\"addressesAsString\" value=\"lcoalhost:11211,localhost:11212\" /\u003e\n\u003c/bean\u003e\n\n\u003cbean id=\"memcachedInterceptor\" class=\"memcachedweaver.interceptor.MemcachedInterceptor\"/\u003e\n\n\u003caop:config\u003e\n  \u003caop:advisor advice-ref=\"memcachedInterceptor\" pointcut=\"...\"/\u003e\n\u003c/aop:config\u003e\n```\n\n### Setup by inheritence\n\nIt's also possible to inject the configuration to interceptor by inheritence.\n\n```java\npublic class MyMemcachedInterceptor extends MemcachedInterceptor {\n\n  @Override\n  public Configuration getConfiguration() {\n    Configuration config = new Configuration();\n    config.setNamespace(\"....\");\n    ...\n    return config;\n  }\n\n}\n```\n\n### Using AOP\n\nThe value will be cached for the duration of 10 seconds.\n\n```java\npackage service;\n\nimport memcachedweaver.annotation.Memcached;\n\npublic class DateService {\n\n  @Memcached(secondsToExpire = 10)\n  public String getCurrentAsString(String prefix) {\n    return prefix + new java.util.Date().toString();\n  }\n\n}\n```\n\n### The rule of generated cache key\n\n```\n\"(namespace)::(Method#toGenericString() and replace \"\\\\s+\" to \"_\")::(args separated by comma)\"\n```\n\nFor example:\n\n```java\nString result = new DateService().getCurrentAsString(\"PREFIX\");\n```\n\nAnd thn, the returned value will be cached as \"com.example::public_void_service.DateService.getCurrentAsString(String)::PREFIX\" on memcached.\n\n\n## License\n\n```java\n/*\n * Copyright 2011 Kazuhiro Sera\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n * either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseratch%2Fmemcachedweaver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseratch%2Fmemcachedweaver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseratch%2Fmemcachedweaver/lists"}