Class InMemoryStickyBucketServiceImpl

java.lang.Object
growthbook.sdk.java.stickyBucketing.InMemoryStickyBucketServiceImpl
All Implemented Interfaces:
StickyBucketService

public class InMemoryStickyBucketServiceImpl extends Object implements StickyBucketService
For simple bucket persistence using the in memory's storage(Map) (can be polyfilled for other environments)
  • Constructor Details

    • InMemoryStickyBucketServiceImpl

      public InMemoryStickyBucketServiceImpl(Map<String,StickyAssignmentsDocument> localStorage)
      Constructs a new InMemoryStickyBucketServiceImpl with the specified local storage.
      Parameters:
      localStorage - a map to store sticky assignments documents in memory.
  • Method Details

    • getAssignments

      public StickyAssignmentsDocument getAssignments(String attributeName, String attributeValue)
      Method for getting all assignments document from cache (in memory: hashmap)
      Specified by:
      getAssignments in interface StickyBucketService
      Parameters:
      attributeName - attributeName with attributeValue together present a key that us for find proper StickyAssignmentsDocument
      attributeValue - attributeName with attributeValue together present a key that us for find proper StickyAssignmentsDocument
      Returns:
      StickyAssignmentsDocument
    • saveAssignments

      public void saveAssignments(StickyAssignmentsDocument doc)
      Method for saving assignments document to cache (in memory: hashmap)
      Specified by:
      saveAssignments in interface StickyBucketService
      Parameters:
      doc - StickyAssignmentsDocument
    • getAllAssignments

      public Map<String,StickyAssignmentsDocument> getAllAssignments(Map<String,String> attributes)
      Method for getting sticky bucket assignments from cache (in memory: hashmap) by attributes of context
      Specified by:
      getAllAssignments in interface StickyBucketService
      Parameters:
      attributes - Map of String key and String value that you have in GBContext
      Returns:
      Map with key String and value StickyAssignmentsDocument