UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'YMN2VqW0sXhaP5KV+q9alGSD1X+9XfqopqvMTo5I1Aw=' 
WHERE 
  key_id = '3de9a4ce094f9aa24f69b647f191b6c33708f7602b22088c5007c866b56bb905' 
  AND (
    token = 'YMN2VqW0sXhaP5KV+q9alGSD1X+9XfqopqvMTo5I1Aw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00025