sql >> データベース >  >> NoSQL >> Redis

タイプされたトランザクションをRedis

    ServiceStackのC#Redisクライアントによって実装されたRedisトランザクションインターフェイス。

    はじめに#

    Redisトランザクションインターフェイスは、単一のトランザクション内でIRedisTypedClient操作をキューに入れることができる便利なオーバーロードを提供します。 APIはコールバックのサポートを提供するため、トランザクションの一部として返される戻り値にもアクセスできます。

    使用法#

    以下は、トランザクションにアクセスし、使用し、コミットする方法を示す簡単な例です。

    var typedClient = Redis.GetTypedClient<MyPocoType>();			
    using (var trans = typedClient.CreateTransaction())
    {
        trans.QueueCommand(r => r.Set("nosqldbs", new MyPocoType {Id = 1, Name = "Redis"));
    
        trans.Commit();
    }
    

    文字列値を操作するトランザクションについては、IRedisTransactionを参照してください。

    詳細#

    public interface IRedisTypedTransaction<T> 
        : IDisposable
    {
        void QueueCommand(Action<IRedisTypedClient<T>> command);
        void QueueCommand(Action<IRedisTypedClient<T>> command, Action onSuccessCallback);
        void QueueCommand(Action<IRedisTypedClient<T>> command, Action onSuccessCallback, Action<Exception> onErrorCallback);
    
        void QueueCommand(Func<IRedisTypedClient<T>, int> command);
        void QueueCommand(Func<IRedisTypedClient<T>, int> command, Action<int> onSuccessCallback);
        void QueueCommand(Func<IRedisTypedClient<T>, int> command, Action<int> onSuccessCallback, Action<Exception> onErrorCallback);
    
        void QueueCommand(Func<IRedisTypedClient<T>, bool> command);
        void QueueCommand(Func<IRedisTypedClient<T>, bool> command, Action<bool> onSuccessCallback);
        void QueueCommand(Func<IRedisTypedClient<T>, bool> command, Action<bool> onSuccessCallback, Action<Exception> onErrorCallback);
    
        void QueueCommand(Func<IRedisTypedClient<T>, double> command);
        void QueueCommand(Func<IRedisTypedClient<T>, double> command, Action<double> onSuccessCallback);
        void QueueCommand(Func<IRedisTypedClient<T>, double> command, Action<double> onSuccessCallback, Action<Exception> onErrorCallback);
    
        void QueueCommand(Func<IRedisTypedClient<T>, byte[]> command);
        void QueueCommand(Func<IRedisTypedClient<T>, byte[]> command, Action<byte[]> onSuccessCallback);
        void QueueCommand(Func<IRedisTypedClient<T>, byte[]> command, Action<byte[]> onSuccessCallback, Action<Exception> onErrorCallback);
    
        void QueueCommand(Func<IRedisTypedClient<T>, string> command);
        void QueueCommand(Func<IRedisTypedClient<T>, string> command, Action<string> onSuccessCallback);
        void QueueCommand(Func<IRedisTypedClient<T>, string> command, Action<string> onSuccessCallback, Action<Exception> onErrorCallback);
    
        void QueueCommand(Func<IRedisTypedClient<T>, T> command);
        void QueueCommand(Func<IRedisTypedClient<T>, T> command, Action<T> onSuccessCallback);
        void QueueCommand(Func<IRedisTypedClient<T>, T> command, Action<T> onSuccessCallback, Action<Exception> onErrorCallback);
    
        void QueueCommand(Func<IRedisTypedClient<T>, List<string>> command);
        void QueueCommand(Func<IRedisTypedClient<T>, List<string>> command, Action<List<string>> onSuccessCallback);
        void QueueCommand(Func<IRedisTypedClient<T>, List<string>> command, Action<List<string>> onSuccessCallback, Action<Exception> onErrorCallback);
    
        void QueueCommand(Func<IRedisTypedClient<T>, List<T>> command);
        void QueueCommand(Func<IRedisTypedClient<T>, List<T>> command, Action<List<T>> onSuccessCallback);
        void QueueCommand(Func<IRedisTypedClient<T>, List<T>> command, Action<List<T>> onSuccessCallback, Action<Exception> onErrorCallback);
    
        void Commit();
        void Rollback();
    }
    

    1. エラーメッセージ:MongoError:bad auth Authentication failed through URI string

    2. RedisINCRの同時実行性

    3. Laravel 4:未定義のメソッドRedis ::connection()の呼び出し

    4. MongoDBでのマルチドキュメントACIDトランザクションの概要とその使用方法