Hi,
We create a cache using SQL DDL syntax.
How can I configure Cassandra persistent store to the cache in .NET
application ?
It seems like default CacheConfiguration is automatically applied
internally in Java codes for SQL cache, so not able to load up Spring.XML
for that cache.
Here is the steps creating a SQL cache.
/Ignite: 2.6
OS: Windows Server 2016
Jdk: Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
Programming language: C#/
*a)*
// Create dummy cache to act as an entry point for SQL queries (new SQL API
which do not require this
// will appear in future versions, JDBC and ODBC drivers do not require it
already).
var cacheCfg = new CacheConfiguration(m_odbcCacheName)
{
SqlSchema = "PUBLIC",
CacheMode = CacheMode.Replicated
};
m_odbcCache = m_ignite.GetOrCreateCache<object, object>(cacheCfg);
*b)*
// Create a VALUE_TYPE class
public class UserData : IBinarizable
{
[QuerySqlField]
public DateTime LastUpdated { get; set; }
[QuerySqlField]
public byte[] Data { get; set; }
public UserData() { }
public UserData(byte[] btUserData)
{
LastUpdated = DateTime.UtcNow;
Data = btUserData;
}
public void WriteBinary(IBinaryWriter writer)
{
writer.WriteTimestamp(nameof(LastUpdated), LastUpdated);
writer.WriteByteArray(nameof(Data), Data);
}
public void ReadBinary(IBinaryReader reader)
{
LastUpdated = reader.ReadTimestamp(nameof(LastUpdated)) ??
DateTime.UtcNow;
Data = reader.ReadByteArray(nameof(Data));
}
}
*c)*
// Crete an actual UserData cache by running a DDL query on entry point
cache.
var qry = @"
CREATE TABLE IF NOT EXISTS [name]
(
CacheKey VARCHAR,
AffinityKey LONG,
LastUpdated TIMESTAMP,
Data VARBINARY(MAX),
PRIMARY KEY (CacheKey, AffinityKey)
)
WITH ""BACKUPS=2, TEMPLATE=PARTITIONED,
WRITE_SYNCHRONIZATION_MODE=PRIMARY_SYNC, AFFINITYKEY=AffinityKey,
VALUE_TYPE=UserData""
";
var qryResults = m_odbcCache.Query(new SqlFieldsQuery(qry)).GetAll();
Thanks
Sam
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/