// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements.  See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License.  You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
= Cache Storage

Ignite Caches are designed as temporary storage for rapid response "cache" of data that may be required for local operation.

Cache data is always stored in a special *cache store*. By default, the cache maintains a weak consistency with the remote storage.

== Difference Between Caches and Tables

Unlike tables, in Ignite caches do not have persistence or store transaction history. This means that caches also do not support read-only transactions and continuous queries, as those features rely on transaction history to ensure consistency.

Fields in caches cannot be nullable.

== Creating a Cache

Caches are created by using the DDL link:/sql-reference/create-cache[CREATE CACHE] command, for example:

[source, SQL]
----
CREATE CACHE person (
    id INT PRIMARY KEY,
    name VARCHAR,
    ttl TIMESTAMP
) EXPIRE AT ttl;
----

When creating a cache, it must use the `aimem` storage type.

== Working With Caches

Cache API completely mirrors the link:developers-guide/table-api[table] API.

== Cache Modes

Ignite supports 2 modes:

- In write-through mode, the cache maintains strong consistency with the storage.
- In write-behind mode, the cache maintains eventual consistency with the storage. This may cause consistency issues, but does improve performance.
//- In reverse replication mode, the cache does not write data