This explains basic usage of the Sakai MemoryService. This service manages and is used to create and retrieve information about existing caches.
- Trunk javadocs:
- Trunk source location: https://source.sakaiproject.org/svn/kernel/trunk/api/src/main/java/org/sakaiproject/memory/
Accessing the MemoryService
- You can use Spring Framework to inject the service or use the cover
- Using Spring to get the service for your class (e.g. YourAppClass) (recommended)
Add the MemoryService bean to the bean for YourAppClass
Add a variable and setter to YourAppClass to use the service in like so:
- Using the Component Manager to get the service
- Note: This is not the recommended method, you should be using Spring to inject the service
Use the CM cover to get the service
Getting a Cache by name
Use the service variable to access the service and request a Cache. This will create one if needed or retrieve an existing one if it was created earlier.
Note: This returns a Sakai Cache object