Hash :: compatto

Un implementazione dell'oggetto basato su hash con alias chiave e supporto del valore predefinito
Scarica ora

Hash :: compatto Classifica e riepilogo

Annuncio pubblicitario

  • Rating:
  • Licenza:
  • Perl Artistic License
  • Nome editore:
  • Kentaro Kuribayashi
  • Sito web dell'editore:
  • http://search.cpan.org/~kentaro/

Hash :: compatto Tag


Hash :: compatto Descrizione

Un implementazione dell'oggetto basato su hash con alias chiave e supporto del valore predefinito Quando memorizziamo un valore strutturato in una colonna di un database relazionale o di un po 'di archiviazione chiave / valore, la ridondanza dei nomi dei tasti lunghi può essere un problema per lo spazio di archiviazione. Kash :: Compact è un modulo perl, ancora un altro implementazione dell'oggetto basato su hash che Mira a essere consapevole dell'efficienza spaziale e della facilità di utilizzo per US.synopsis Package My :: Memcached; usare rigoroso; Utilizzare Avvertenze; Usa il genitore QW (cache :: Memcached :: Veloce); usa json; Usa Hash :: Compact; My $ options = {foo => {alias_for => 'f',}, barre => {alias_for => 'b', default => 'bar', default => 'BAR',},}; sub get {my ($ sé, $ key) = @_; My $ Value = $ Self-> Super :: Get ($ key); Hash :: Compact-> nuovo (Decode_json $ Value, $ opzioni); } Sub Set {My ($ sé, $ key, $ Value, $ scadenza) = @_; My $ Hash = hash :: Compact-> Nuovo ($ valore, $ opzioni); $ self-> super :: set ($ key, encode_json $ hash-> to_hash, $ scadenza); } pacchetto principale; usare rigoroso; Utilizzare Avvertenze; Usa Test :: altro; My $ Key = 'Key'; My $ Value = {foo => 'foo'}; My $ Memd = My :: MemCached-> Nuovo ({Server => }); $ Memd-> Set ($ key, $ Value); My $ Cached_Value = $ Memd-> Get ($ key); is_deeply $ cached_value-> param ('foo'), 'foo'; is_deeply $ cached_value-> param ('bar'), 'bar'; is_deeply $ cached_value-> to_hash, + {f => 'foo'}; $ cached_value-> param (bar => 'baz'); $ Memd-> Set ($ key, $ cached_value-> to_hash); $ cached_valuet = $ memd-> get ($ key); is_deeply $ cached_value-> param ('foo'), 'foo'; is_deeply $ cached_value-> param ('bar'), 'baz'; is_deeply $ cached_value-> to_hash, + {f => 'foo', b => 'baz'}; Done_testing; Requisiti: · Perl.


Hash :: compatto Software correlato