UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'A+52fvyygb+t5JLk08Rdj7+yuLgQNE48nyClpBt1gTE=' 
WHERE 
  key_id = '4020c969a9f5db611f706d11760fec90981565cc8651588ad8b17de44042a730' 
  AND (
    token = 'A+52fvyygb+t5JLk08Rdj7+yuLgQNE48nyClpBt1gTE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024