Example #1
0
        /// <summary>
        /// Saves the given <paramref name="data"/> into the cache storage and identifies it by the given <paramref name="name"/>
        /// </summary>
        /// <param name="name">The name to identify the cached data by</param>
        /// <param name="data">The data to cache</param>
        /// <param name="timestamp">The timestamp of when the cached object was created</param>
        public void Store(string name, PyDataType data, long timestamp)
        {
            byte[] marshalData = Marshal.ToByteArray(data);

            CachedHint hint = CachedHint.FromPyObject(name, marshalData, timestamp, this.Container.NodeID);

            // save cache hint
            this.mCacheHints[name] = hint;
            // save cache object
            this.mCacheData[name] = CachedObject.FromCacheHint(hint, marshalData);
        }
Example #2
0
        /// <summary>
        /// Saves the given <paramref name="data"/> into the cache storage and identifies it by the <paramref name="service"/> and <paramref name="method"/> that generated it
        /// </summary>
        /// <param name="service">The service that generated the cached object</param>
        /// <param name="method">The method that generated the cached object</param>
        /// <param name="data">The data to cache</param>
        /// <param name="timestamp">The timestamp of when the cached object was generated</param>
        public void StoreCall(string service, string method, PyDataType data, long timestamp)
        {
            byte[] marshalData = Marshal.ToByteArray(data);

            string     index    = $"{service}::{method}";
            PyDataType objectID = this.GenerateObjectIDForCall(service, method);
            CachedHint hint     = CachedHint.FromPyObject(objectID, marshalData, timestamp, this.Container.NodeID);

            // save cache hint
            this.mCacheHints[index] = hint;
            // save cache object
            this.mCacheData[index] = CachedObject.FromCacheHint(hint, marshalData);
        }