
Security News
CISA Kills Off RSS Feeds for KEVs and Cyber Alerts
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
ΠΠ°Π±ΠΎΡ ΡΡΡΡΠΊΡΡΡ Π΄Π°Π½Π½ΡΡ Π½Π° Π±Π°Π·Π΅ Redis.
Π‘ΡΠ΅ΡΡΠΈΠΊ Π½Π° ΠΎΡΠ½ΠΎΠ²Π΅ Hash, Ρ ΠΏΡΠ΅ΡΠ΅ΡΠ°Π½ΡΠΎΠΌ ΠΈ ΡΠ°ΠΉΠΊΠ°ΠΌΠΈ-Π±Π»ΠΈΠ·Π½ΡΡΠΊΠ°ΠΌΠΈ ΠΏΠ°ΡΡΠΈΡΠΈΠΎΠ½ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΠΈ ΠΊΠ»Π°ΡΡΠ΅ΡΠΈΠ·Π°ΡΠΈΠ΅ΠΉ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ.
ΠΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΡΠ΅ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΡ: counter_name, field_name ΠΈΠ»ΠΈ group_keys.
ΠΡΠΎΡΡΠΎΠΉ ΡΡΠ΅ΡΡΠΈΠΊ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ.
counter = RedisCounters::HashCounter.new(redis, {
:counter_name => :simple_counter,
:field_name => :pages
})
5.times { counter.increment }
redis:
simple_counter = {
pages => 5
}
> counter.partitions
=> [{}]
> counter.data
=> [{:value=>5}]
Π‘ΡΠ΅ΡΡΠΈΠΊ ΠΏΠΎΡΠ΅ΡΠ΅Π½Π½ΡΡ ΡΡΡΠ°Π½ΠΈΡ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈ Ρ ΠΏΠ°ΡΡΠΈΡΠΈΠΎΠ½ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΠΏΠΎ Π΄Π°ΡΠ΅.
counter = RedisCounters::HashCounter.new(redis, {
:counter_name => :pages_by_day,
:group_keys => [:company_id],
:partition_keys => [:date]
})
2.times { counter.increment(:company_id => 1, :date => '2013-08-01') }
3.times { counter.increment(:company_id => 2, :date => '2013-08-01') }
1.times { counter.increment(:company_id => 3, :date => '2013-08-02') }
redis:
pages_by_day:2013-08-01 = {
1 => 2
2 => 3
}
pages_by_day:2013-08-02 = {
3 => 1
}
> counter.partitions
=> [{:date=>"2013-08-01"}, {:date=>"2013-08-02"}]
> counter.data
=> [{:company_id=>"1", :value=>2},
{:company_id=>"2", :value=>3},
{:company_id=>"3", :value=>1}]
> counter.delete_partitions!(:date => '2013-08-01')
=> [1]
> counter.partitions
=> [{:date=>"2013-08-02"}]
> counter.data
=> [{:company_id=>"3", :value=>1}]
> counter.delete_all!
=> [1]
> counter.data
=> []
Π’ΠΎΠΆΠ΅ ΡΠ°ΠΌΠΎΠ΅, Π½ΠΎ ΠΏΠ°ΡΡΠΈΡΠΈΡ Π·Π°Π΄Π°Π΅ΡΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ proc.
counter = RedisCounters::HashCounter.new(redis, {
:counter_name => :pages_by_day,
:group_keys => [:company_id],
:partition_keys => proc { |params| params.fetch(:date) }
})
Π‘ΡΠ΅ΡΡΠΈΠΊ ΠΏΠΎΡΠ΅ΡΠ΅Π½Π½ΡΡ ΡΡΡΠ°Π½ΠΈΡ Ρ Π³ΡΡΠΏΠΏΠΈΡΠΎΠ²ΠΊΠΎΠΉ ΠΏΠΎ Π³ΠΎΡΠΎΠ΄Ρ ΠΏΠΎΡΠ΅ΡΠΈΡΠ΅Π»Ρ ΠΈ ΠΏΠ°ΡΡΠΈΡΠΈΠΎΠ½ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΠΏΠΎ Π΄Π°ΡΠ΅ ΠΈ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈ.
counter = RedisCounters::HashCounter.new(redis, {
:counter_name => :pages_by_day_city,
:group_keys => [:company_id, :city_id],
:partition_keys => [:date, :company_id]
})
2.times { counter.increment(:date => '2013-08-01', :company_id => 1, :city_id => 11) }
1.times { counter.increment(:date => '2013-08-01', :company_id => 1, :city_id => 12) }
4.times { counter.increment(:date => '2013-08-01', :company_id => 2, :city_id => 10) }
3.times { counter.increment(:date => '2013-08-02', :company_id => 1, :city_id => 15) }
redis:
pages_by_day_city:2013-08-01:1 = {
1:11 => 2,
1:12 => 1
}
pages_by_day_city:2013-08-01:2 = {
2:10 => 4
}
pages_by_day_city:2013-08-02:1 = {
1:15 => 3
}
> counter.partitions
=> [{:date=>"2013-08-02", :company_id=>"1"},
{:date=>"2013-08-01", :company_id=>"1"},
{:date=>"2013-08-01", :company_id=>"2"}]
> counter.partitions(:date => '2013-08-01')
=> [{:date=>"2013-08-01", :company_id=>"1"},
{:date=>"2013-08-01", :company_id=>"2"}]
> counter.data
=> [{:company_id => 1, :city_id=>"15", :value=>3},
{:company_id => 1, :city_id=>"11", :value=>2},
{:company_id => 1, :city_id=>"12", :value=>1},
{:company_id => 2, :city_id=>"10", :value=>4}]
> counter.data(:date => '2013-08-01')
=> [{:company_id => 1, :city_id=>"11", :value=>2},
{:company_id => 1, :city_id=>"12", :value=>1},
{:company_id => 2, :city_id=>"10", :value=>4}]
> counter.data(:date => '2013-08-01') { |batch| puts batch }
{:company_id => 1, :city_id=>"11", :value=>2}
{:company_id => 1, :city_id=>"12", :value=>1}
{:company_id => 2, :city_id=>"10", :value=>4}
Π‘ΠΏΠΈΡΠΎΠΊ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΡ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ, Ρ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡΡ ΠΊΠ»Π°ΡΡΠ΅ΡΠΈΠ·Π°ΡΠΈΠΈ ΠΈ ΠΏΠ°ΡΡΠΈΡΠΈΠΎΠ½ΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ.
ΠΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΠΈ:
ΠΠ΅ΡΠΎΡΡΠ½ΠΎ, Π² ΡΡΠ»ΠΎΠ²ΠΈΡΡ Π±ΠΎΠ»ΡΡΠΎΠΉ ΠΊΠΎΠ½ΠΊΡΡΠ΅Π½ΡΠ½ΠΎΡΡΠΈ, ΠΎΠ±Π»Π°Π΄Π°Π΅Ρ Π½Π΅ Π»ΡΡΡΠ΅ΠΉ ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡΠ΅Π»ΡΠ½ΠΎΡΡΡ ΠΈΠ·-Π·Π° ΡΠ°ΡΡΡΡ Π±Π»ΠΎΠΊΠΈΡΠΎΠ²ΠΎΠΊ.
ΠΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΡΠ΅ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΡ: counter_name ΠΈ value_keys.
ΠΡΠΎΡΡΠΎΠΉ ΡΠΏΠΈΡΠΎΠΊ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΉ.
counter = RedisCounters::UniqueValuesLists::Blocking.new(redis, {
:counter_name => :users,
:value_keys => [:user_id]
})
counter.increment(:user_id => 1)
counter.increment(:user_id => 2)
counter.increment(:user_id => 1)
redis:
users = ['1', '2']
Π‘ΠΏΠΈΡΠΎΠΊ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΉ, ΠΏΠΎΡΠ΅ΡΠΈΠ²ΡΠΈΡ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈΡ, Π·Π° ΠΌΠ΅ΡΡΡ, ΠΏΠ°ΡΡΠΈΡΠΈΠΎΠ½ΠΈΡΠΎΠ²Π°Π½Π½ΡΠΉ ΠΏΠΎ ΡΡΡΠΊΠ°ΠΌ.
counter = RedisCounters::UniqueValuesLists::Blocking.new(redis, {
:counter_name => :company_users_by_month,
:value_keys => [:company_id, :user_id],
:cluster_keys => [:start_month_date],
:partition_keys => [:date]
})
2.times { counter.add(:company_id => 1, :user_id => 11, :date => '2013-08-10', :start_month_date => '2013-08-01') }
3.times { counter.add(:company_id => 1, :user_id => 22, :date => '2013-08-10', :start_month_date => '2013-08-01') }
3.times { counter.add(:company_id => 1, :user_id => 22, :date => '2013-09-05', :start_month_date => '2013-09-01') }
3.times { counter.add(:company_id => 2, :user_id => 11, :date => '2013-08-10', :start_month_date => '2013-08-01') }
1.times { counter.add(:company_id => 2, :user_id => 22, :date => '2013-08-11', :start_month_date => '2013-08-01') }
redis:
company_users_by_month:2013-08-01:partitions = ['2013-08-10', '2013-08-11']
company_users_by_month:2013-08-01:2013-08-10 = ['1:11', '1:22', '2:11']
company_users_by_month:2013-08-01:2013-08-11 = ['2:22']
company_users_by_month:2013-09-01:partitions = ['2013-09-05']
company_users_by_month:2013-09-01:2013-09-05 = ['1:22']
ΠΡΡΡΡΡΠΉ ΡΠΏΠΈΡΠΎΠΊ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΡ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ, Ρ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡΡ ΠΊΠ»Π°ΡΡΠ΅ΡΠΈΠ·Π°ΡΠΈΠΈ ΠΈ ΠΏΠ°ΡΡΠΈΡΠΈΠΎΠ½ΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ.
Π‘ΠΊΠΎΡΠΎΡΡΡ ΡΠ°Π±ΠΎΡΡ Π΄ΠΎΡΡΠΈΠ³Π°Π΅ΡΡΡ Π·Π° ΡΡΠ΅Ρ ΡΠ»Π΅Π΄ΡΡΡΠΈΡ ΠΎΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΠ΅ΠΉ:
ΠΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΡΠ΅ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΡ: counter_name ΠΈ value_keys.
Π‘ΠΏΠΈΡΠΎΠΊ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΡ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ, Ρ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡΡ expire ΠΎΡΠ΄Π΅Π»ΡΠ½ΡΡ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ².
ΠΠ° ΠΎΡΠ½ΠΎΠ²Π΅ ΡΠΎΡΡΠΈΡΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π°. http://redis4you.com/code.php?id=010
ΠΠ° ΠΎΡΠ½ΠΎΠ²Π΅ ΠΌΠ΅Ρ Π°Π½ΠΈΠ·ΠΌΠ° ΠΎΠΏΡΠΈΠΌΠΈΡΡΠΈΡΠ΅ΡΠΊΠΈΡ Π±Π»ΠΎΠΊΠΈΡΠΎΠ²ΠΎΠΊ. ΡΠΌΠΎΡΡΠΈ Optimistic locking using check-and-set: http://redis.io/topics/transactions
ΠΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΠΈ:
ΠΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΡΠ΅ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΡ: counter_name ΠΈ value_keys. Π’Π°ΠΉΠΌΠ°ΡΡ Π·Π°Π΄Π°Π΅ΡΡΡ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠΎΠΌ :expire. ΠΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ :never. :clean_expired - ΡΠ΅ΠΆΠΈΠΌ Π°Π²ΡΠΎΠΎΡΠΈΡΡΠΊΠΈ. ΠΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ true.
counter = RedisCounters::UniqueValuesLists::Expirable.new(redis,
:counter_name => :sessions,
:value_keys => [:session_id],
:expire => 10.minutes
)
counter << session_id: 1
counter << session_id: 2
counter << session_id: 3, expire: :never
counter.data
> [{session_id: 1}, {session_id: 2}, {session_id: 3}]
# after 10 minutes
counter.data
> [{session_id: 3}]
counter.has_value?(session_id: 1)
false
Π‘Π±ΠΎΡΠ½Π°Ρ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΈΡ Π½Π° ΠΎΡΠ½ΠΎΠ²Π΅ ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠΈΡ . HashCounter, Ρ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡΡ ΠΏΠΎΠ΄ΡΡΠ΅ΡΠ° ΡΠΎΠ»ΡΠΊΠΎ Ρ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΡ ΡΠΎΠ±ΡΡΠΈΠΉ.
Π°Π½Π°Π»ΠΎΠ³ΠΈΡΠ½ΠΎ ΡΠ»ΠΎΠΆΠ½ΠΎΡΡΠΈ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΠΎΠ³ΠΎ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΠΎΠ³ΠΎ ΡΠΏΠΈΡΠΊΠ°.
Π‘ΡΠ΅ΡΡΠΈΠΊ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΉ, ΠΏΠΎΡΠ΅ΡΠΈΠ²ΡΠΈΡ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈΡ, Π·Π° ΠΌΠ΅ΡΡΡ, ΠΊΠ»Π°ΡΡΠ΅ΡΠΈΠ·ΠΎΠ²Π°Π½Π½ΡΠΉ ΠΏΠΎ ΡΡΡΠΊΠ°ΠΌ.
counter = RedisCounters::UniqueHashCounter.new(redis, {
:counter_name => :company_users_by_month,
:group_keys => [:company_id],
:partition_keys => [:date],
:unique_list => {
:list_class => RedisCounters::UniqueValuesLists::Blocking
:value_keys => [:company_id, :user_id],
:cluster_keys => [:start_month_date],
:partition_keys => [:date]
}
})
2.times { counter.increment(:company_id => 1, :user_id => 11, :date => '2013-08-10', :start_month_date => '2013-08-01') }
3.times { counter.increment(:company_id => 1, :user_id => 22, :date => '2013-08-10', :start_month_date => '2013-08-01') }
3.times { counter.increment(:company_id => 1, :user_id => 22, :date => '2013-09-05', :start_month_date => '2013-09-01') }
3.times { counter.increment(:company_id => 2, :user_id => 11, :date => '2013-08-10', :start_month_date => '2013-08-01') }
1.times { counter.increment(:company_id => 2, :user_id => 22, :date => '2013-08-11', :start_month_date => '2013-08-01') }
redis:
company_users_by_month:2013-08-10 = {
1 = 2,
2 = 1
}
company_users_by_month:2013-08-11 = {
2 = 1
}
company_users_by_month:2013-09-05 = {
1 = 1
}
company_users_by_month_uq:2013-08-01:partitions = ['2013-08-10', '2013-08-11']
company_users_by_month_uq:2013-08-01:2013-08-10 = ['1:11', '1:22', '2:11']
company_users_by_month_uq:2013-08-01:2013-08-11 = ['2:22']
company_users_by_month_uq:2013-09-01:partitions = ['2013-09-05']
company_users_by_month_uq:2013-09-01:2013-09-05 = ['1:22']
FAQs
Unknown package
We found that redis_counters demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.