{"id":23124859,"url":"https://github.com/playframework/play2-memcached","last_synced_at":"2025-04-12T22:34:45.072Z","repository":{"id":2767157,"uuid":"3765654","full_name":"playframework/play2-memcached","owner":"playframework","description":"A memcached plugin for Play 2.x","archived":false,"fork":false,"pushed_at":"2024-11-28T10:34:46.000Z","size":2338,"stargazers_count":161,"open_issues_count":22,"forks_count":65,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-04-11T03:23:40.243Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"lemonde/angular-ckeditor","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/playframework.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},"funding":{"github":["playframework"],"open_collective":"playframework"}},"created_at":"2012-03-19T16:04:25.000Z","updated_at":"2025-01-28T15:58:00.000Z","dependencies_parsed_at":"2024-10-26T21:15:18.183Z","dependency_job_id":"6c0b4810-311a-4c01-a41a-b652617d7876","html_url":"https://github.com/playframework/play2-memcached","commit_stats":{"total_commits":171,"total_committers":17,"mean_commits":"10.058823529411764","dds":0.5029239766081872,"last_synced_commit":"869890c8ed4c5fa62c03136cd2c4d807eab797ea"},"previous_names":["playframework/play2-memcached"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playframework%2Fplay2-memcached","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playframework%2Fplay2-memcached/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playframework%2Fplay2-memcached/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playframework%2Fplay2-memcached/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/playframework","download_url":"https://codeload.github.com/playframework/play2-memcached/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248642308,"owners_count":21138350,"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-12-17T08:08:48.788Z","updated_at":"2025-04-12T22:34:45.052Z","avatar_url":"https://github.com/playframework.png","language":"Scala","readme":"Memcached Plugin for Play framework 2.x\n---------------------------------------\n\nA Memcached implementation of Cache API for Play 2.x.\nUsing spymemcached internally, which is the same as Play 1.x's default Cache implementation.\n\n## Usage\n\nAdd the following dependency to your Play project:\n\n### Library dependencies\n\nFor Play 2.6.x and newer:\n!!! Changed `play.modules.cache.*` config keys to `play.cache.*` !!!\n\n```scala\n  val appDependencies = Seq(\n    play.PlayImport.cacheApi,\n    \"com.github.mumoshu\" %% \"play2-memcached-play26\" % \"0.9.2\"\n  )\n  val main = Project(appName).enablePlugins(play.PlayScala).settings(\n    version := appVersion,\n    libraryDependencies ++= appDependencies,\n    resolvers += \"Spy Repository\" at \"http://files.couchbase.com/maven2\" // required to resolve `spymemcached`, the plugin's dependency.\n  )\n```\n\nFor Play 2.5.x:\n\n```scala\n  val appDependencies = Seq(\n    play.PlayImport.cache,\n    \"com.github.mumoshu\" %% \"play2-memcached-play25\" % \"0.8.0\"\n  )\n  val main = Project(appName).enablePlugins(play.PlayScala).settings(\n    version := appVersion,\n    libraryDependencies ++= appDependencies,\n    resolvers += \"Spy Repository\" at \"http://files.couchbase.com/maven2\" // required to resolve `spymemcached`, the plugin's dependency.\n  )\n```\n\nFor Play 2.4.x:\n\n```scala\n  val appDependencies = Seq(\n    play.PlayImport.cache,\n    \"com.github.mumoshu\" %% \"play2-memcached-play24\" % \"0.7.0\"\n  )\n  val main = Project(appName).enablePlugins(play.PlayScala).settings(\n    version := appVersion,\n    libraryDependencies ++= appDependencies,\n    resolvers += \"Spy Repository\" at \"http://files.couchbase.com/maven2\" // required to resolve `spymemcached`, the plugin's dependency.\n  )\n```\n\nFor Play 2.3.x:\n\n```scala\n  val appDependencies = Seq(\n    play.PlayImport.cache,\n    \"com.github.mumoshu\" %% \"play2-memcached-play23\" % \"0.7.0\"\n  )\n  val main = Project(appName).enablePlugins(play.PlayScala).settings(\n    version := appVersion,\n    libraryDependencies ++= appDependencies,\n    resolvers += \"Spy Repository\" at \"http://files.couchbase.com/maven2\" // required to resolve `spymemcached`, the plugin's dependency.\n  )\n```\n\nFor Play 2.2.0:\n\n```scala\n  val appDependencies = Seq(\n    cache, // or play.Project.cache if not imported play.Project._\n    \"com.github.mumoshu\" %% \"play2-memcached\" % \"0.4.0\" // or 0.5.0-RC1 to try the latest improvements\n  )\n  val main = play.Project(appName, appVersion, appDependencies).settings(\n    resolvers += \"Spy Repository\" at \"http://files.couchbase.com/maven2\" // required to resolve `spymemcached`, the plugin's dependency.\n  )\n```\n\n\nFor Play 2.1.0:\n\n```scala\n  val appDependencies = Seq(\n    \"com.github.mumoshu\" %% \"play2-memcached\" % \"0.3.0.3\"\n  )\n  val main = play.Project(appName, appVersion, appDependencies).settings(\n    resolvers += \"Spy Repository\" at \"http://files.couchbase.com/maven2\" // required to resolve `spymemcached`, the plugin's dependency.\n  )\n```\n\nFor Play 2.0:\n\n```scala\n  val appDependencies = Seq(\n    \"com.github.mumoshu\" %% \"play2-memcached\" % \"0.2.4.3\"\n  )\n  val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(\n    resolvers += \"Spy Repository\" at \"http://files.couchbase.com/maven2\" // required to resolve `spymemcached`, the plugin's dependency.\n  )\n```\n\n### Configurations\n\n#### Starting with Play 2.6.x\n\n```\nplay.modules.enabled+=\"com.github.mumoshu.play2.memcached.MemcachedModule\"\n\n# Well-known configuration provided by Play\nplay.cache.defaultCache=default\nplay.cache.bindCaches=[\"db-cache\", \"user-cache\", \"session-cache\"]\n\n# Tell play2-memcached where your memcached host is located at\nmemcached.host=\"127.0.0.1:11211\"\n```\n\n#### For Play 2.4.x and above\n\n```\nplay.modules.enabled+=\"com.github.mumoshu.play2.memcached.MemcachedModule\"\n\n# To avoid conflict with play2-memcached's Memcached-based cache module\nplay.modules.disabled+=\"play.api.cache.EhCacheModule\"\n\n# Well-known configuration provided by Play\nplay.modules.cache.defaultCache=default\nplay.modules.cache.bindCaches=[\"db-cache\", \"user-cache\", \"session-cache\"]\n\n# Tell play2-memcached where your memcached host is located at\nmemcached.host=\"127.0.0.1:11211\"\n```\n\n#### Play 2.3.x or below\n\nAdd a reference to the plugin in `play.plugins` file.\n`play.plugins` file must be put somewhere in the classpath.\nMy recommendation is to put it in `conf/` directory.\n\n```\n  5000:com.github.mumoshu.play2.memcached.MemcachedPlugin\n```\n\nFirst of all, in `application.conf`, disable the EhCachePlugin - Play's default implementation of CacheAPI:\n\n```\n  ehcacheplugin=disabled\n```\n\nSpecify the host name or IP address of the memcached server, and the port number:\n\n```\n  memcached.host=\"127.0.0.1:11211\"\n```\n\nIf you have multiple memcached instances over different host names or IP addresses, provide them like:\n\n```\n  memcached.1.host=\"mumocached1:11211\"\n  memcached.2.host=\"mumocached2:11211\"\n```\n\n### Code examples\n\n#### For Play 2.4.x and above\n\nSee the Play Framework documentation for the [Scala](https://www.playframework.com/documentation/2.6.x/ScalaCache) and [Java](https://www.playframework.com/documentation/2.6.x/JavaCache) API.\n\n#### For Play 2.3.x or below\n\nThen, you can use the `play.api.cache.Cache` object to store a value in memcached:\n\n```scala\n Cache.set(\"key\", \"theValue\")\n```\n\nThis way, memcached tries to retain the stored value eternally.\nOf course Memcached does not guarantee eternity of the value, nor can it retain the value on restart.\n\nIf you want the value expired after some time:\n\n```scala\n Cache.set(\"key\", \"theValueWithExpirationTime\", 3600)\n // The value expires after 3600 seconds.\n```\n\nTo get the value for a key:\n\n```scala\n val theValue = Cache.getAs[String](\"key\")\n```\n\nYou can remove the value (It's not yet a part of Play 2.0's Cache API, though):\n\n```scala\n play.api.Play.current.plugin[MemcachedPlugin].get.api.remove(\"keyToRemove\")\n```\n\n### Advanced configurations\n\n#### Disabling the plugin (For Play 2.3.x or below)\n\nYou can disable the plugin in a similar manner to Play's build-in Ehcache Plugin.\nTo disable the plugin in `application.conf`:\n\n```\n  memcachedplugin=disabled\n```\n\n#### Authentication with SASL\n\nIf you memcached requires the client an authentication with SASL, provide username/password like:\n\n```\n  memcached.user=misaka\n  memcached.password=mikoto\n```\n\n#### Configure logging\n\nBy default, the plugin (or the spymemcached under the hood) does not output any logs at all.\nIf you need to peek into what's going on, set the log level like:\n\n##### For Play 2.4.x and above\n\nIn your `logback.xml`:\n\n```\n  \u003clogger name=\"memcached\" level=\"DEBUG\" /\u003e\n```\n\n#### For Play 2.3.x or below\n\n```\n  logger.memcached=DEBUG\n```\n\n#### Namespacing\n\nYou can prefix every key to put/get/remove with a global namespace.\n\n##### For Play 2.4.x and above\n\nYou can inject an `(ASync)CacheApi` with @play.cache.NamedCache to prefix all the keys you get, set and remove with the given namespace.\nThere is more documentation in the official Play Framework documentation.\n\n```\n  @Inject @play.cache.NamedCache(\"user-cache\") private AsyncCacheApi cacheApi;\n```\n\n##### For Play 2.3.x or below\n\nBy default, the namespace is an empty string, implying you don't use namespacing at all.\nTo enable namespacing, configure it in \"application.conf\":\n\n```\n  memcached.namespace=mikoto.\n```\n\n### Key hashing\n\n**Requires play2-memcached 0.9.0 or later**\n\nYou may consider activating this option to enable support for long keys which are composed of more than 250 characters.\n\nIt is disabled by default like:\n\n```\n  memcached.hashkeys=off\n```\n\nYou can activate it by specifying the name of a message digest algorithm used for hashing:\n\n```\n  memcached.hashkeys=SHA-1\n```\n\nAvailable options are MD2, MD5, SHA-1, SHA-256, SHA-384, SHA-512.\nPlease refer to http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#MessageDigest for the complete list of available algorithms.\n\n### Configuring timeouts\n\nUntil Play version 2.6 you can specify timeouts for obtaining values from Memcached.\nThis option isn't needed anymore since Play 2.6 because since that version Play's cache api is async per default.\n\n```\n  # Timeout in 1 second (only until Play version 2.6)\n  memcached.timeout=1\n```\n\n### Using ElastiCache's Auto-Discovery feature\n\nAt first, download the latest `AmazonElastiCacheClusterClient-*.jar` from the AWS console,\nor build it yourself as described in [The Amazon ElastiCache Cluster Client page in GitHub](https://github.com/amazonwebservices/aws-elasticache-cluster-client-memcached-for-java),\nand put it under `/lib`.\n\nRemove the SBT dependency on spymemcached by excluding it from play2-mamcached's transitive dependencies:\n\n```\n  \"com.github.mumoshu\" %% \"play2-memcached\" % \"0.5.0-RC1 exclude(\"net.spy\", \"spymemcached\")\n```\n\nConfigure your configuration endpoint in `application.conf`:\n\n```\n  elasticache.config.endpoint=\"mycachename.asdfjk.cfg.use1.cache.amazonaws.com:11211\".\n```\n\n### Version history\n\n0.2.2 Fixed the logging leak issue. You don't get a bunch of INFO messages to play app's default logger anymore.\n\n0.2.3 Allow removing keys in both Java and Scala ways described in Play's documentation. See MemcachedIntegrationSpec.scala for how to remove keys in Scala.\n\n0.2.4 Introduced \"namespace\" to prefix every key to put/get/remove with a global namespace configured in \"application.conf\"\n\n0.2.4.1 Updated spymemcached to 2.8.12\n\n0.2.4.3 Updated spymemcached to 2.9.0 which solves the authentication issues.\n\n0.3.0 Built for Play 2.1.0 and available in the Maven Central. Also updated spymemcached to 2.8.4.\n\n0.3.0.1 Updated spymemcached to 2.8.12\n\n0.3.0.2 Reverted spymemcached to 2.8.9 to deal with authentication failures to various memcache servers caused by spymemcached 2.8.10+. See #17 and #20 for details.\n\n0.3.0.3 Updated spymemcached to 2.9.0 which solves the authentication issues.\n\n0.4.0 Build for Play 2.2.0\n\n0.5.0-RC1 Improvements:\n  #14 Adding support for Amazon Elasticache (thanks to @kamatsuoka)\n  #23 Adding configurable timeouts on the future (thanks to @rmmeans)\n  #24 Empty keys - kind of ehcache compilance, avoiding IllegalArgumentExceptions (thanks to @mkubala)\n\n0.7.0 Cross built for Play 2.3.x, 2.4.x, Scala 2.10.5 and 2.11.6. Artifact IDs are renamed to `play2-memcached-play2{3,4}_2.1{0,1}`\n\n0.8.0 Built for Play 2.5.x and Scala 2.11.11. Artifact ID for this build is `play2-memcached-play25_2.11`\n\n0.9.0 Built for Play 2.6.x and Scala 2.11.11 and 2.12.3. Artifact ID for this build is `play2-memcached-play26_2.1{1,2}`\n  !!! Changed `play.modules.cache.*` config keys to `play.cache.*` !!!\n\n0.9.1 Remove global state by removing reference to deprecated Play.current\n\n0.9.2 Fix frozen future in 2.6 API\n\n0.10.0-M1 Built for Play 2.7.0-M1 and Scala 2.11.12 and 2.12.6. Artifact ID for this build is `play2-memcached-play27_2.1{1,2}`\n\n0.10.0-M2 Built for Play 2.7.0-M2 and Scala 2.11.12 and 2.12.6. Artifact ID for this build is `play2-memcached-play27_2.1{1,2}`\n\n0.10.0-RC3 Built for Play 2.7.0-RC8 and Scala 2.11.12 and 2.12.7. Artifact ID for this build is `play2-memcached-play27_2.1{1,2}`\n\n0.10.0 Built for Play 2.7.0 and Scala 2.11.12 and 2.12.8. Artifact ID for this build is `play2-memcached-play27_2.1{1,2}`\n\n0.10.1 Built for Play 2.7.3 and Scala 2.13.0, 2.11.12 and 2.12.8. Artifact ID for this build is `play2-memcached-play27_2.1{1,2,3}`\n\n0.11.0 Built for Play 2.8.0 and Scala 2.13.1 and 2.12.10. Artifact ID for this build is `play2-memcached-play28_2.1{2,3}`\n\n0.12.0 Built for Play 2.9.0 and Scala 2.13.12 and 3.3.1. Artifact ID for this build is `play2-memcached-play29_[2.13|3]`\n\n### Publishing to the central\n\n```\n# Play 2.5\nPLAY_VERSION=2.5.0 sbt ++2.11.12 publishSigned sonatypeRelease\n\n# Play 2.6\nPLAY_VERSION=2.6.0 sbt ++2.12.8 publishSigned sonatypeRelease\n\n# Play 2.7\nPLAY_VERSION=2.7.3 sbt ++2.11.12 publishSigned sonatypeRelease\nPLAY_VERSION=2.7.3 sbt ++2.12.8 publishSigned sonatypeRelease\nPLAY_VERSION=2.7.3 sbt ++2.13.0 publishSigned sonatypeRelease\n\n# Play 2.8\nPLAY_VERSION=2.8.0 sbt ++2.12.10 publishSigned sonatypeRelease\nPLAY_VERSION=2.8.0 sbt ++2.13.1 publishSigned sonatypeRelease\n\n# Play 2.9\nPLAY_VERSION=2.9.0 sbt ++2.13.12 publishSigned sonatypeRelease\nPLAY_VERSION=2.9.0 sbt ++3.3.1 publishSigned sonatypeRelease\n```\n\n### Acknowledgement\n\nThanks to:\n@gakuzzzz for the original idea of \"namespacing\" and the initial pull request for it.\n@kamatsuoka for adding support for Amazon Elasticache.\n@rmmeans for adding configurable timeouts on the future.\n@mkubala for improving compliance with EhCache.\n\n### Build status\n\n[![Build Status](https://secure.travis-ci.org/mumoshu/play2-memcached.png)](http://travis-ci.org/mumoshu/play2-memcached)\n","funding_links":["https://github.com/sponsors/playframework","https://opencollective.com/playframework"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplayframework%2Fplay2-memcached","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplayframework%2Fplay2-memcached","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplayframework%2Fplay2-memcached/lists"}