[[custom_cache_stores]]
=== Custom Cache Stores
If the provided cache stores do not fulfill all of your requirements, it is possible for you to implement your own store.
The steps required to create your own store are as follows:

1. Write your custom store by implementing one of the following interfaces:
* `org.infinispan.persistence.spi.AdvancedCacheWriter`
* `org.infinispan.persistence.spi.AdvancedCacheLoader`
* `org.infinispan.persistence.spi.CacheLoader`
* `org.infinispan.persistence.spi.CacheWriter`
* `org.infinispan.persistence.spi.ExternalStore`
* `org.infinispan.persistence.spi.AdvancedLoadWriteStore`
* `org.infinispan.persistence.spi.TransactionalCacheWriter`
//Exclude segmentation from productized docs.
ifndef::productized[]
* `org.infinispan.persistence.spi.SegmentedAdvancedLoadWriteStore`
endif::productized[]
+
2. Annotate your store class with the `@Store` annotation and specify the properties relevant to your store, e.g. is it
possible for the store to be shared in Replicated or Distributed mode: `@Store(shared = true)`.
+
3. Create a custom cache store configuration and builder. This requires extending `AbstractStoreConfiguration` and `AbstractStoreConfigurationBuilder`.
As an optional step, you should add the following annotations to your configuration - `@ConfigurationFor`, `@BuiltBy` as well
as adding `@ConfiguredBy` to your store implementation class.  These additional annotations will ensure that your custom
configuration builder is used to parse your store configuration from xml. If these annotations are not added, then the
`CustomStoreConfigurationBuilder` will be used to parse the common store attributes defined in `AbstractStoreConfiguration`
and any additional elements will be ignored. If a store and its configuration do not declare the `@Store` and `@ConfigurationFor`
annotations respectively, a warning message will be logged upon cache initialisation.
//Exclude segmentation from productized docs.
ifndef::productized[]
+
If you wish for your store to be segmented, where it will craete a different
store instance per segment, instead of extending `AbstractStoreConfiguration`
you should extend `AbstractSegmentedStoreConfiguration`.
endif::productized[]
+
4. Add your custom store to your cache's configuration:

   a. Add your custom store to the ConfigurationBuilder, for example:

   Configuration config = new ConfigurationBuilder()
               .persistence()
               .addStore(CustomStoreConfigurationBuilder.class)
               .build();

   b. Define your custom store via xml:

   <local-cache name="customStoreExample">
     <persistence>
       <store class="org.infinispan.persistence.dummy.DummyInMemoryStore" />
     </persistence>
   </local-cache>

==== HotRod Deployment
A Custom Cache Store can be packaged into a separate JAR file and deployed in a HotRod server using the following steps:

1. Follow link:#custom_cache_stores[Custom Cache Stores], steps 1-3>> in the previous section and package your implementations in a JAR file (or use a Custom Cache Store Archetype).

2. In your Jar create a proper file under `META-INF/services/`, which contains the fully qualified class name of your store implementation.
The name of this service file should reflect the interface that your store implements. For example, if your store implements
the `AdvancedCacheWriter` interface than you need to create the following file:

   * `/META-INF/services/org.infinispan.persistence.spi.AdvancedCacheWriter`

3. Deploy the JAR file in the {brandname} Server.
//////////////////////////
//terminate unordered list
//////////////////////////
