event_buffer.rb 696 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. module EventBuffer
  3. def self.list(key)
  4. if !Thread.current[:event_buffer]
  5. Thread.current[:event_buffer] = {}
  6. end
  7. Thread.current[:event_buffer][key] || []
  8. end
  9. def self.add(key, item)
  10. if !Thread.current[:event_buffer]
  11. Thread.current[:event_buffer] = {}
  12. end
  13. if !Thread.current[:event_buffer][key]
  14. Thread.current[:event_buffer][key] = []
  15. end
  16. Thread.current[:event_buffer][key].push item
  17. end
  18. def self.reset(key)
  19. return if !Thread.current[:event_buffer]
  20. return if !Thread.current[:event_buffer][key]
  21. Thread.current[:event_buffer][key] = []
  22. end
  23. end