Example #1
0
        public bool Store <T>(StoreOperation operation, T datakey, int expires)
            where T : DataKey
        {
            datakey.Initialize(m_formatter);
            int flags;
            var bytes = datakey.Save(out flags);
            var key   = m_keyEncoder.GetBytes(datakey.Key);

            m_commandWriter.Store(new StorePacket()
            {
                Operation = operation,
                Key       = key,
                Flags     = flags,
                Expires   = expires,
                Value     = bytes,
                Version   = datakey.Version
            }, Options.NoReply);

            var succeed = true;

            return(m_factory.Context(key)((connection, state) =>
            {
                m_builder.WriteTo(connection.Writer);
                if (!Options.NoReply)
                {
                    var commandReader = m_factory.CreateCommandReader(
                        m_factory.CreatePacketParser(connection.Reader, m_buffer));
                    succeed = commandReader.ReadStored();
                }
            }) && succeed);
        }