• Stars
    star
    162
  • Rank 232,284 (Top 5 %)
  • Language
    Scala
  • License
    Other
  • Created over 12 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A memcached plugin for Play 2.x

Memcached Plugin for Play framework 2.x

A Memcached implementation of Cache API for Play 2.x. Using spymemcached internally, which is the same as Play 1.x's default Cache implementation.

Usage

Add the following dependency to your Play project:

Library dependencies

For Play 2.6.x and newer: !!! Changed play.modules.cache.* config keys to play.cache.* !!!

  val appDependencies = Seq(
    play.PlayImport.cacheApi,
    "com.github.mumoshu" %% "play2-memcached-play26" % "0.9.2"
  )
  val main = Project(appName).enablePlugins(play.PlayScala).settings(
    version := appVersion,
    libraryDependencies ++= appDependencies,
    resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
  )

For Play 2.5.x:

  val appDependencies = Seq(
    play.PlayImport.cache,
    "com.github.mumoshu" %% "play2-memcached-play25" % "0.8.0"
  )
  val main = Project(appName).enablePlugins(play.PlayScala).settings(
    version := appVersion,
    libraryDependencies ++= appDependencies,
    resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
  )

For Play 2.4.x:

  val appDependencies = Seq(
    play.PlayImport.cache,
    "com.github.mumoshu" %% "play2-memcached-play24" % "0.7.0"
  )
  val main = Project(appName).enablePlugins(play.PlayScala).settings(
    version := appVersion,
    libraryDependencies ++= appDependencies,
    resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
  )

For Play 2.3.x:

  val appDependencies = Seq(
    play.PlayImport.cache,
    "com.github.mumoshu" %% "play2-memcached-play23" % "0.7.0"
  )
  val main = Project(appName).enablePlugins(play.PlayScala).settings(
    version := appVersion,
    libraryDependencies ++= appDependencies,
    resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
  )

For Play 2.2.0:

  val appDependencies = Seq(
    cache, // or play.Project.cache if not imported play.Project._
    "com.github.mumoshu" %% "play2-memcached" % "0.4.0" // or 0.5.0-RC1 to try the latest improvements
  )
  val main = play.Project(appName, appVersion, appDependencies).settings(
    resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
  )

For Play 2.1.0:

  val appDependencies = Seq(
    "com.github.mumoshu" %% "play2-memcached" % "0.3.0.3"
  )
  val main = play.Project(appName, appVersion, appDependencies).settings(
    resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
  )

For Play 2.0:

  val appDependencies = Seq(
    "com.github.mumoshu" %% "play2-memcached" % "0.2.4.3"
  )
  val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
    resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
  )

Configurations

Starting with Play 2.6.x

play.modules.enabled+="com.github.mumoshu.play2.memcached.MemcachedModule"

# Well-known configuration provided by Play
play.cache.defaultCache=default
play.cache.bindCaches=["db-cache", "user-cache", "session-cache"]

# Tell play2-memcached where your memcached host is located at
memcached.host="127.0.0.1:11211"

For Play 2.4.x and above

play.modules.enabled+="com.github.mumoshu.play2.memcached.MemcachedModule"

# To avoid conflict with play2-memcached's Memcached-based cache module
play.modules.disabled+="play.api.cache.EhCacheModule"

# Well-known configuration provided by Play
play.modules.cache.defaultCache=default
play.modules.cache.bindCaches=["db-cache", "user-cache", "session-cache"]

# Tell play2-memcached where your memcached host is located at
memcached.host="127.0.0.1:11211"

Play 2.3.x or below

Add a reference to the plugin in play.plugins file. play.plugins file must be put somewhere in the classpath. My recommendation is to put it in conf/ directory.

  5000:com.github.mumoshu.play2.memcached.MemcachedPlugin

First of all, in application.conf, disable the EhCachePlugin - Play's default implementation of CacheAPI:

  ehcacheplugin=disabled

Specify the host name or IP address of the memcached server, and the port number:

  memcached.host="127.0.0.1:11211"

If you have multiple memcached instances over different host names or IP addresses, provide them like:

  memcached.1.host="mumocached1:11211"
  memcached.2.host="mumocached2:11211"

Code examples

For Play 2.4.x and above

See the Play Framework documentation for the Scala and Java API.

For Play 2.3.x or below

Then, you can use the play.api.cache.Cache object to store a value in memcached:

 Cache.set("key", "theValue")

This way, memcached tries to retain the stored value eternally. Of course Memcached does not guarantee eternity of the value, nor can it retain the value on restart.

If you want the value expired after some time:

 Cache.set("key", "theValueWithExpirationTime", 3600)
 // The value expires after 3600 seconds.

To get the value for a key:

 val theValue = Cache.getAs[String]("key")

You can remove the value (It's not yet a part of Play 2.0's Cache API, though):

 play.api.Play.current.plugin[MemcachedPlugin].get.api.remove("keyToRemove")

Advanced configurations

Disabling the plugin (For Play 2.3.x or below)

You can disable the plugin in a similar manner to Play's build-in Ehcache Plugin. To disable the plugin in application.conf:

  memcachedplugin=disabled

Authentication with SASL

If you memcached requires the client an authentication with SASL, provide username/password like:

  memcached.user=misaka
  memcached.password=mikoto

Configure logging

By default, the plugin (or the spymemcached under the hood) does not output any logs at all. If you need to peek into what's going on, set the log level like:

For Play 2.4.x and above

In your logback.xml:

  <logger name="memcached" level="DEBUG" />

For Play 2.3.x or below

  logger.memcached=DEBUG

Namespacing

You can prefix every key to put/get/remove with a global namespace.

For Play 2.4.x and above

You can inject an (ASync)CacheApi with @play.cache.NamedCache to prefix all the keys you get, set and remove with the given namespace. There is more documentation in the official Play Framework documentation.

  @Inject @play.cache.NamedCache("user-cache") private AsyncCacheApi cacheApi;
For Play 2.3.x or below

By default, the namespace is an empty string, implying you don't use namespacing at all. To enable namespacing, configure it in "application.conf":

  memcached.namespace=mikoto.

Key hashing

Requires play2-memcached 0.9.0 or later

You may consider activating this option to enable support for long keys which are composed of more than 250 characters.

It is disabled by default like:

  memcached.hashkeys=off

You can activate it by specifying the name of a message digest algorithm used for hashing:

  memcached.hashkeys=SHA-1

Available options are MD2, MD5, SHA-1, SHA-256, SHA-384, SHA-512. Please refer to http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#MessageDigest for the complete list of available algorithms.

Configuring timeouts

Until Play version 2.6 you can specify timeouts for obtaining values from Memcached. This option isn't needed anymore since Play 2.6 because since that version Play's cache api is async per default.

  # Timeout in 1 second (only until Play version 2.6)
  memcached.timeout=1

Using ElastiCache's Auto-Discovery feature

At first, download the latest AmazonElastiCacheClusterClient-*.jar from the AWS console, or build it yourself as described in The Amazon ElastiCache Cluster Client page in GitHub, and put it under /lib.

Remove the SBT dependency on spymemcached by excluding it from play2-mamcached's transitive dependencies:

  "com.github.mumoshu" %% "play2-memcached" % "0.5.0-RC1 exclude("net.spy", "spymemcached")

Configure your configuration endpoint in application.conf:

  elasticache.config.endpoint="mycachename.asdfjk.cfg.use1.cache.amazonaws.com:11211".

Version history

0.2.2 Fixed the logging leak issue. You don't get a bunch of INFO messages to play app's default logger anymore.

0.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.

0.2.4 Introduced "namespace" to prefix every key to put/get/remove with a global namespace configured in "application.conf"

0.2.4.1 Updated spymemcached to 2.8.12

0.2.4.3 Updated spymemcached to 2.9.0 which solves the authentication issues.

0.3.0 Built for Play 2.1.0 and available in the Maven Central. Also updated spymemcached to 2.8.4.

0.3.0.1 Updated spymemcached to 2.8.12

0.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.

0.3.0.3 Updated spymemcached to 2.9.0 which solves the authentication issues.

0.4.0 Build for Play 2.2.0

0.5.0-RC1 Improvements: #14 Adding support for Amazon Elasticache (thanks to @kamatsuoka) #23 Adding configurable timeouts on the future (thanks to @rmmeans) #24 Empty keys - kind of ehcache compilance, avoiding IllegalArgumentExceptions (thanks to @mkubala)

0.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}

0.8.0 Built for Play 2.5.x and Scala 2.11.11. Artifact ID for this build is play2-memcached-play25_2.11

0.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} !!! Changed play.modules.cache.* config keys to play.cache.* !!!

0.9.1 Remove global state by removing reference to deprecated Play.current

0.9.2 Fix frozen future in 2.6 API

0.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}

0.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}

0.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}

0.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}

0.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}

0.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}

Publishing to the central

# Play 2.5
PLAY_VERSION=2.5.0 sbt ++2.11.12 publishSigned sonatypeRelease

# Play 2.6
PLAY_VERSION=2.6.0 sbt ++2.12.8 publishSigned sonatypeRelease

# Play 2.7
PLAY_VERSION=2.7.3 sbt ++2.11.12 publishSigned sonatypeRelease
PLAY_VERSION=2.7.3 sbt ++2.12.8 publishSigned sonatypeRelease
PLAY_VERSION=2.7.3 sbt ++2.13.0 publishSigned sonatypeRelease

# Play 2.8
PLAY_VERSION=2.8.0 sbt ++2.12.10 publishSigned sonatypeRelease
PLAY_VERSION=2.8.0 sbt ++2.13.1 publishSigned sonatypeRelease

Acknowledgement

Thanks to: @gakuzzzz for the original idea of "namespacing" and the initial pull request for it. @kamatsuoka for adding support for Amazon Elasticache. @rmmeans for adding configurable timeouts on the future. @mkubala for improving compliance with EhCache.

Build status

Build Status

More Repositories

1

kube-airflow

A docker image and kubernetes config files to run Airflow on Kubernetes
Python
649
star
2

aws-secret-operator

A Kubernetes operator that automatically creates and updates Kubernetes secrets according to what are stored in AWS Secrets Manager.
Go
309
star
3

variant

Wrap up your bash scripts into a modern CLI today. Graduate to a full-blown golang app tomorrow.
Go
301
star
4

terraform-provider-eksctl

Manage AWS EKS clusters using Terraform and eksctl
Go
232
star
5

helm-x

Treat any Kustomization or K8s manifests directory as a Helm chart
Go
169
star
6

variant2

Turn your bash scripts into a modern, single-executable CLI app today
Go
134
star
7

terraform-provider-helmfile

Deploy Helmfile releases from Terraform
Go
115
star
8

kube-ssm-agent

Secure, access-controlled, and audited terminal sessions to EKS nodes without SSH
Dockerfile
106
star
9

kube-spot-termination-notice-handler

Moved to https://github.com/kube-aws/kube-spot-termination-notice-handler
Shell
97
star
10

concourse-aws

Auto-scaling Concourse CI v2.2.1 on AWS with Terraform (since 2016.04.14)
Go
72
star
11

play2-typescript

TypeScript assets handling for Play 2.0. Compiles .ts files under the /assets dir along with the project.
Scala
72
star
12

crossover

Minimal sufficient Envoy xDS for Kubernetes that knows https://smi-spec.io/
Go
71
star
13

helmfile-operator

Kubernetes operator that continuously syncs any set of Chart/Kustomize/Manifest fetched from S3/Git/GCS to your cluster
Go
62
star
14

okra

Hot-swap Kubernetes clusters while keeping your service up and running.
Go
48
star
15

decouple-apps-and-eks-clusters-with-tf-and-gitops

Smarty
31
star
16

kodedeploy

CodeDeploy for EKS. Parallel and Continuous (re)delivery to multiple EKS clusters. Blue-green deployment "of" EKS clusters.
Shell
29
star
17

config-registry

Switch between kubeconfigs and avoid unintentional operation on your production clusters.
Go
28
star
18

gosh

(Re)write your bash script in Go and make it testable too
Go
24
star
19

tiny-mmo

A work-in-progress example of server-side implementation of a tiny massive multi-player online game, implemented with Scala 2.10.2 and Akka 2.2
Java
23
star
20

geohash-scala

Geohash library for scala
Scala
23
star
21

prometheus-process-exporter

Helml chart for Prometheus process-exporter
Mustache
22
star
22

waypoint-plugin-helmfile

Helmfile deployment plugin for HashiCorp Waypoint
Go
15
star
23

kube-magic-ip-address

daemonset that assigns a magic IP address to pods. Useful for implementing node-local services on Kubernetes. Use in combination with dd-agent, dd-zipkin-proxy, kube2iam, kiam, and Elastic's apm-server
Shell
15
star
24

kube-fluentd

An ubuntu-slim/s6-overlay/confd based docker image for running fluentd in Kubernetes pods/daemonsets
Makefile
15
star
25

node-detacher

Practically and gracefully stop your K8s node on (termination|scale down|maintenance)
Go
13
star
26

kube-node-init

Kubernetes daemonset for node initial configuration. Currently for modifying files and systemd services on eksctl nodes without changing userdata
Smarty
13
star
27

lambda_bot

JavaScript
12
star
28

argocd-clusterset

A command-line tool and Kubernetes controller to sync EKS clusters into ArgoCD cluster secrets
Go
12
star
29

dcind

Docker Compose (and Daemon) in Docker
Shell
12
star
30

flux-repo

Enterprise-grade secrets management for GitOps
Go
10
star
31

brigade-helmfile-demo

Demo for building an enhanced GitOps pipeline with Flux, Brigade and Helmfile
JavaScript
9
star
32

kubeherd

A opinionated toolkit to automate herding your cattles = ephemeral Kubernetes clusters
Shell
9
star
33

sopsed

Spawning and storage of secure environments powered by sops, inspired from vaulted. Out-of-box support for kubectl, kube-aws, helm, helmfile
Go
9
star
34

helmfile-gitops

8
star
35

nodelocaldns

Temporary location of the nodelocaldns chart until it is upstreamed to helm/charts
Smarty
8
star
36

kube-logrotate

An ubuntu-slim/s6-overlay/confd based docker image for running logrotate via Kubernetes daemonsets
Makefile
7
star
37

idea-play

A plugin for IntelliJ IDEA which supports development of Play framework applications.
Java
7
star
38

actions-runner-controller-ci

Test repo for https://github.com/summerwind/actions-runner-controller
Go
6
star
39

kargo

Deploy your Kubernetes application directly or indirectly
Go
6
star
40

shoal

Declarative, Go-embeddable, and cross-platform package manager powered by https://gofi.sh/
Go
6
star
41

ingress-daemonset-controller

Build your own highly available and efficient external ingress loadbalancer on Kubernetes
Go
6
star
42

conflint

Unified lint runners for various configuration files
Go
5
star
43

fluent-plugin-datadog-log

Sends logs to Datadog Log Management: A port/translation of https://github.com/DataDog/datadog-log-agent to a Fluentd plugin
Ruby
5
star
44

play20-zentasks-tests

Added spec2 tests to Play20's 'zentasks
Scala
4
star
45

nomidroid

Android app to find nearby restaurants, bars, etc with Recruit Web API
Java
4
star
46

versapack

Versatile package manager. Version and host anything in Helm charts repositories
4
star
47

vote4music-play20

A Play 2.0 RC1 port of https://github.com/loicdescotte/vote4music
Scala
4
star
48

homebrew-anyenv

Ruby
4
star
49

terraform-provider-kubectl

Run kubectl against multiple K8s clusters in a single terraform-apply. AWS auth/AssumeRole supported.
Go
3
star
50

kube-node-index-prioritizing-scheduler

Kubernetes scheduler extender that uses sorted nodes' positions as priorities. Use in combination with resource request/limit to implement low-latency highly available front proxy cluster
Go
3
star
51

depot

Ruby
2
star
52

kokodoko

JavaScript
2
star
53

brigade-cd

Go
2
star
54

scripts

my scripts for linux machines
Shell
2
star
55

courier

Go
2
star
56

nodejs-chat

JavaScript
2
star
57

ooina

JavaScript
2
star
58

play-websocket-growl-sample

A sample application notifies the server on Growl, and other users via WebSocket
Java
2
star
59

heartbeat-operator

Monitor any http and tcp services via Kubernetes custom resources
Shell
2
star
60

brigade-automation

TypeScript
2
star
61

nbxmpfilter

xmpfilter for NetBeans
2
star
62

play-scala-lobby-example

Java/Scala mixed app with a WebSocketController in Java, while others are in Scala.
JavaScript
2
star
63

wy

Go
2
star
64

docker-squid-gem-proxy

Dockerfile for building docker image to run Squid-based reverse proxies to rubygems.org, for speeding-up `gem install` or `bundle install`
Shell
2
star
65

hcl2-yaml

YAML syntax for HashiCorp Configuration Language Version 2
Go
2
star
66

tweet_alarm_clock_android

Java
2
star
67

testkit

A toolkit for writing Go tests for your cloud apps, infra-as-code, and gitops configs
Go
1
star
68

elasticdrone

A set of tools to configure auto-scaled Drone.io cluster on AWS in ease
JavaScript
1
star
69

kubeaws-cicd-pipeline-golang

An example of the opinionated deployment pipeline for your Kubernetes-on-AWS-native apps. Secure, declarative, customizable, open app deployments at your hand.
Shell
1
star
70

akka-parallel-tasks

Scala
1
star
71

sing

1
star
72

good-code-is-red-example-for-idea-scala-plugin

Scala
1
star
73

share-snippets

JavaScript
1
star
74

scala-scalable-programming-sidenote

Scala
1
star
75

teleport-on-minikube

Shell
1
star
76

genrun

Go
1
star
77

nomidroid_test

tests for nomidroid the android app.
Java
1
star
78

web_smartphonizer

Scala
1
star
79

idobata4s

The Scala client library for idobata.io API
Scala
1
star
80

specs2-sandbox

Scala
1
star
81

kube-distributed-test-runner

Go
1
star
82

delimited-continuation

An example usage of Delimited Continuation in Scala,;implementing an async HTTP client.
Scala
1
star
83

play2-unit-tests-sample

1
star
84

syaml

Set YAML values with `cat your.yaml | syaml a.b.c newValue`
Go
1
star
85

scala-debian-package

1
star
86

glabel

A GOverlay implementation for putting text labels on GMap2
JavaScript
1
star
87

gitops-demo

Makefile
1
star
88

division

Control-plane of your microservices and Kubernetes clusters
Go
1
star
89

sam-containerized-go-example

Go
1
star
90

mumoauth

Yet another implementation of OAuth aiming to cover both OAuth 1.0a and 2, from Client to Server.
Scala
1
star
91

javascript-missiles-and-lasers

JavaScript
1
star
92

kube-veneur

Sidecar container to run local veneur and Kubernetes service for global https://github.com/stripe/veneur. Uses confd and s6-overlay under the hood.
Makefile
1
star
93

tweet_alarm_clock_android_test

Java
1
star
94

thread_local

An implementation of the thread-local variable for Ruby
Ruby
1
star
95

play-multijpa

a Play! plugin to switch databases for each play.db.jpa.Model subclass
Java
1
star
96

argocd-example-apps

Jsonnet
1
star
97

javascript-hue_circle

Draw a hue circle in JavaScript
JavaScript
1
star
98

logrus-bunyan-formatter

Logrus Bunyan Log Formatter
Go
1
star
99

crdb

Custom Resource DB - Kubernetes custom resources without Kubernetes or self-hosted databases. For any cloud, by leveraging cloudprovider-specific managed databases like AWS DynamoDB
Go
1
star