UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'hdJdg1Yu4GcFM/DZX2JHcJvK2+NrIbutZaxIZ+60nmE=' 
WHERE 
  key_id = '217cc1cc2a1a9274c7947a041440ac1c1d54b409462cff547f7d51b3159b6f25' 
  AND (
    token = 'hdJdg1Yu4GcFM/DZX2JHcJvK2+NrIbutZaxIZ+60nmE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038