UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'UYaiB7kTWcZSQcW74q1WBauYXdoYett1UGNiel2KBbs=' 
WHERE 
  key_id = '0fe5ee7d4ad933ec65586952e56b5965d724be26ff64c44c8de174e332f86598' 
  AND (
    token = 'UYaiB7kTWcZSQcW74q1WBauYXdoYett1UGNiel2KBbs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00022